Re: ReadDirectoryChangesW seem to looses events?

From: Phil Ten (pt_at_dafweb.com)
Date: 07/19/04


Date: Mon, 19 Jul 2004 11:09:53 +0100

Thank you for your post.

I tried a to queue a second "ReadDirectoryChangesW",
unfortunately, it did not help.

If you want to check it, I posted more information on
this issue in another post below (reply to Rhett Gong post)

Thank you.

Phil Ten.

"Alexander Grigoriev" <alegr@earthlink.net> wrote in message
news:eIwOm15aEHA.3988@tk2msftngp13.phx.gbl...
> Try to queue two pending ReadDirChanges
>
> "Phil Ten" <pt@dafweb.com> wrote in message
> news:OWfWAdzaEHA.3524@TK2MSFTNGP12.phx.gbl...
> > In order to monitor files added into
> > a directory I use functions "ReadDirectoryChangesW"
> > asynchronously with function "GetQueuedCompletionStatus"
> > and a completion port in a loop.
> > (extract of my code copied below.)
> >
> > When I paste many files (i.e. 50 files) into
> > the watched directory, it works for most of the
> > files, except for a few for which no notification
> > is received. I mention that the watched directory
> > is local (not a shared remote directory)
> >
> > I assume that missing notifications matches
> > events which would have arrived
> > after "GetQueuedCompletionStatus"
> > returned and before "ReadDirectoryChangesW"
> > was Re-issue. Does this diagnostic seem
> > correct? If it does, what can I do to fix it?
> >
> > In all cases, a workaround with which all
> > files added to my watched directory
> > would be notified for sure, would be very appreciated?
> >
> > For some reason, my loop thread works
> > only if I call "SleepEx(1,TRUE)"
> > before re-issuying the watch
> > command (code velow).
> > Would someone have a idea why?
> >
> > Thank you in advance for all help
> > or comments.
> >
> > Phil. Ten.
> >
> > Code extract below:
> > (error handling removed)
> >
> > ---------------------------------
> >
> > class DIRECTORY_INFO
> > {
> > public:
> > DIRECTORY_INFO();
> > ~DIRECTORY_INFO();
> > HANDLE hDir;
> > TCHAR lpszDirName[MAX_PATH];
> > CHAR lpBuffer[MAX_BUFFER];
> > DWORD dwBufLength;
> > OVERLAPPED Overlapped;
> > DWORD NotifyFilter;
> > };
> > typedef DIRECTORY_INFO *LPDIRECTORY_INFO;
> >
> > -----------------------------------------------------------------
> > //Thread 1
> >
> > DirInfo = new DIRECTORY_INFO();
> >
> > ....
> >
> > DirInfo->hDir = CreateFile(DirInfo->lpszDirName,FILE_LIST_DIRECTORY,
> > FILE_SHARE_READ |
> > FILE_SHARE_WRITE |
> > FILE_SHARE_DELETE,
> > NULL,
> > OPEN_EXISTING,
> > FILE_FLAG_BACKUP_SEMANTICS |
> > FILE_FLAG_OVERLAPPED,
> > NULL);
> >
> > hCompPort=CreateIoCompletionPort(DirInfo->hDir, hCompPort,(DWORD)
> > DirInfo,0);
> >
> > Err = ReadDirectoryChangesW(DirInfo->hDir,
> >
DirInfo->lpBuffer,
> > MAX_BUFFER,
> > FALSE,
> >
> > DirInfo->NotifyFilter,
> >
> > &DirInfo->dwBufLength,&DirInfo->Overlapped,
> > NULL);
> >
> >
> > //Starts Thread 2 with code below
> >
> > -----------------------------------------------------------------
> > //Thread 2
> >
> > LPDIRECTORY_INFO di;
> > do
> > {
> > Err = GetQueuedCompletionStatus(WatchedDirList.hCompPort,
> > &numBytes,
> > (LPDWORD)
&di,
> >
&lpOverlapped,
> > INFINITE);
> >
> > //Required.
> > //Otherwise GetQueuedCompletionStatus above never exit
> > //WHY?????
> > SleepEx(1,TRUE);
> >
> > fni = (PFILE_NOTIFY_INFORMATION)di->lpBuffer;
> > do
> > {
> > //Notification processing: start a new process and return.
> > CheckChangedFile(fni->Action, fni->FileName);
> >
> > fni = (PFILE_NOTIFY_INFORMATION)((LPBYTE) fni + cbOffset);
> >
> > } while( cbOffset );
> >
> > // Reissue the watch command
> > Err = ReadDirectoryChangesW( di->hDir,di->lpBuffer,
> > MAX_BUFFER,
> > FALSE,
> > di->NotifyFilter,
> > &di->dwBufLength,
> > &di->Overlapped,
> > NULL);
> >
> > } while( di ); //di=NULL => quit requested
> >
> > ---------------------------------
> >
> >
> >
>
>



Relevant Pages

  • [PATCH 06/12] fsnotify: generic notification queue and waitq
    ... on a queue until the listener is ready to receive it. ... implements a generic notification queue for inotify to ... * hold real event information we just keep one system wide and use it any time ...
    (Linux-Kernel)
  • Re: Remote notification of presubmission queue exceeding set value?
    ... Why don't you use the script notification feature in ESM, ... > method of being remotely notified if the queue exceeds a set amount, ... when the SMTP service is plugged!? ... > I thought about getting another vendor's event log monitor that has it's ...
    (microsoft.public.exchange.admin)
  • Re: Sendmail ignores -N never option for DSNs?
    ... Sendmail connects to the nominated MX for the sender, ... I don't want this second part happening for the mail in the queue. ... -N dsn Set delivery status notification conditions to dsn, ...
    (comp.mail.sendmail)
  • Sendmail ignores -N never option for DSNs?
    ... Sendmail connects to the nominated MX for the sender, and sends a DSN. ... I don't want this second part happening for the mail in the queue. ... -N dsn Set delivery status notification conditions to dsn, ...
    (comp.mail.sendmail)
  • [PATCH -V2 07/13] fsnotify: generic notification queue and waitq
    ... on a queue until the listener is ready to receive it. ... implements a generic notification queue for inotify to ... extern struct list_head fsnotify_groups; ... * hold real event information we just keep one system wide and use it any time ...
    (Linux-Kernel)