What steps will reproduce the problem?
1. load code DLL
2. fw = new FileWatcher
3. fw->addWatch("SameDir")
4. delete fw
5. unload code DLL
6. load code DLL
7. fw = new FileWatcher
8. fw->addWatch("SameDir")
What is the expected output? What do you see instead?
when the second code dll is loaded the OS executes a WatchCallback with a
WatchStruct ( passed in lpOverlapped ) that is already destroyed. ( I have
dumped the pointers with outputdebugstring ). The dwNumberOfBytesTransfered
varies. Returning when the size is 0 is not enough, sometimes its a bigger
value. To fix the issue I have made the following modification:
bool RefreshWatch(WatchStruct* pWatch,bool _clear = false)
{
return ReadDirectoryChangesW(pWatch->mDirHandle, pWatch->mBuffer,
sizeof(pWatch->mBuffer), FALSE, pWatch->mNotifyFilter, NULL,
&pWatch->mOverlapped, _clear ? 0 : WatchCallback) != 0;
}
This allows me to clear the callback ( _clear ? 0 : WatchCallback ). The
deactivation of the callback is done in DestroyWatch:
CancelIo(pWatch->mDirHandle);
--> RefreshWatch(pWatch,true);
if (!HasOverlappedIoCompleted(&pWatch->mOverlapped))
I also return immediately when dwNumberOfBytesTransfered is 0 in the
WatchCallback
void CALLBACK WatchCallback(DWORD dwErrorCode, DWORD
dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped)
{
if (dwNumberOfBytesTransfered == 0)
return;
What version of the product are you using? On what operating system?
2009.05.14. Vista Ultimate 64Bit
Please provide any additional information below.
Original issue reported on code.google.com by Markus.O...@gmail.com on 2 Sep 2009 at 3:33
Original issue reported on code.google.com by
Markus.O...@gmail.com
on 2 Sep 2009 at 3:33