From 541b3dff430cc31643d257dff15ec6eb9971785d Mon Sep 17 00:00:00 2001 From: Chris Howey Date: Mon, 17 Jun 2013 18:11:16 -0500 Subject: [PATCH] Windows - fix up handling of ERROR_MORE_DATA --- fsnotify_windows.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 { -- 2.50.1