Re: ReadDirectoryChangesW seem to looses events?
From: Phil Ten (pt_at_dafweb.com)
Date: 07/19/04
- Next message: Chuck Chopp: "Re: How list all current logon NT domain users?"
- Previous message: Phil Ten: "Re: ReadDirectoryChangesW seem to looses events?"
- In reply to: Alexander Grigoriev: "Re: ReadDirectoryChangesW seem to looses events?"
- Next in thread: Rhett Gong [MSFT]: "RE: ReadDirectoryChangesW seem to looses events?"
- Messages sorted by: [ date ] [ thread ]
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
> >
> > ---------------------------------
> >
> >
> >
>
>
- Next message: Chuck Chopp: "Re: How list all current logon NT domain users?"
- Previous message: Phil Ten: "Re: ReadDirectoryChangesW seem to looses events?"
- In reply to: Alexander Grigoriev: "Re: ReadDirectoryChangesW seem to looses events?"
- Next in thread: Rhett Gong [MSFT]: "RE: ReadDirectoryChangesW seem to looses events?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|