kernel32: ReadDirectoryChangesW fixes.
ReadDirectoryChangesW remembers whether it's recording changes or not.
Don't initialize overlapped->InternalHigh.
The hEvent is cleared when ReadDirectoryChanges is called.
diff --git a/server/change.c b/server/change.c
index d6213fe..c35a82c 100644
--- a/server/change.c
+++ b/server/change.c
@@ -141,6 +141,7 @@
struct event *event;
unsigned int filter; /* notification filter */
int notified; /* SIGIO counter */
+ int want_data; /* return change data */
long signaled; /* the file changed */
struct fd *inotify_fd; /* inotify file descriptor */
int wd; /* inotify watch descriptor */
@@ -254,6 +255,7 @@
dir->filter = 0;
dir->notified = 0;
dir->signaled = 0;
+ dir->want_data = 0;
dir->inotify_fd = NULL;
dir->wd = -1;
grab_object( fd );
@@ -412,20 +414,23 @@
{
struct change_record *record;
- record = malloc( sizeof (*record) + ie->len - 1 ) ;
- if (!record)
- return;
+ if (dir->want_data)
+ {
+ record = malloc( sizeof (*record) + ie->len - 1 ) ;
+ if (!record)
+ return;
- if( ie->mask & IN_CREATE )
- record->action = FILE_ACTION_ADDED;
- else if( ie->mask & IN_DELETE )
- record->action = FILE_ACTION_REMOVED;
- else
- record->action = FILE_ACTION_MODIFIED;
- memcpy( record->name, ie->name, ie->len );
- record->len = strlen( ie->name );
+ if( ie->mask & IN_CREATE )
+ record->action = FILE_ACTION_ADDED;
+ else if( ie->mask & IN_DELETE )
+ record->action = FILE_ACTION_REMOVED;
+ else
+ record->action = FILE_ACTION_MODIFIED;
+ memcpy( record->name, ie->name, ie->len );
+ record->len = strlen( ie->name );
- list_add_tail( &dir->change_records, &record->entry );
+ list_add_tail( &dir->change_records, &record->entry );
+ }
if (!list_empty( &dir->change_q ))
async_terminate_head( &dir->change_q, STATUS_ALERTED );
@@ -551,12 +556,17 @@
{
insert_change( dir );
dir->filter = req->filter;
+ dir->want_data = req->want_data;
}
/* remove any notifications */
if (dir->signaled>0)
dir->signaled--;
+ /* clear the event */
+ if (event)
+ reset_event( event );
+
/* setup the real notification */
#ifdef USE_INOTIFY
if (!inotify_adjust_changes( dir ))