From: Chris Howey Date: Mon, 17 Jun 2013 23:11:16 +0000 (-0500) Subject: Windows - fix up handling of ERROR_MORE_DATA X-Git-Tag: v1.7.2~347 X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=541b3dff430cc31643d257dff15ec6eb9971785d;p=fsnotify.git Windows - fix up handling of ERROR_MORE_DATA --- diff --git a/fsnotify_windows.go b/fsnotify_windows.go index fd70a2b..04dd5a0 100644 --- a/fsnotify_windows.go +++ b/fsnotify_windows.go @@ -42,7 +42,7 @@ const ( ) const ( - ERROR_MORE_DATA syscall.Errno = 234 + sys_ERROR_MORE_DATA syscall.Errno = 234 ) // Event is the type of the notification messages @@ -442,15 +442,14 @@ func (w *Watcher) readEvents() { } switch e { - case ERROR_MORE_DATA: + case sys_ERROR_MORE_DATA: if watch == nil { w.Error <- errors.New("ERROR_MORE_DATA has unexpectedly null lpOverlapped buffer") } else { //The i/o succeeded but buffer is full //in theory we should be building up a full packet //in practice we can get away with just carrying on - //should be len(watch.buf) possibly? - n = 4096 + n = uint32(unsafe.Sizeof(watch.buf)) } case syscall.ERROR_ACCESS_DENIED: // Watched directory was probably removed @@ -526,6 +525,12 @@ func (w *Watcher) readEvents() { break } offset += raw.NextEntryOffset + + // Error! + if offset >= n { + w.Error <- errors.New("Windows system assumed buffer larger than it is, events have likely been missed.") + break + } } if err := w.startRead(watch); err != nil {