From 3dff0dbb90ac299730c7cb94f60ce3ca7aeae2de Mon Sep 17 00:00:00 2001 From: janwas Date: Wed, 11 Aug 2004 23:25:09 +0000 Subject: [PATCH] re-enable warning when ReadDirectoryChanges fails (underlying problem solved) This was SVN commit r976. --- source/lib/sysdep/win/wdir_watch.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/lib/sysdep/win/wdir_watch.cpp b/source/lib/sysdep/win/wdir_watch.cpp index ffd1d7b3a8..5d4590048d 100755 --- a/source/lib/sysdep/win/wdir_watch.cpp +++ b/source/lib/sysdep/win/wdir_watch.cpp @@ -214,6 +214,7 @@ int dir_add_watch(const char* const dir, intptr_t* const _reqnum) try { Watch* w = new Watch(reqnum, dir_s, hDir); + assert(w != 0); // happened once; heap corruption? // add trailing \ if not already there if(dir_s[dir_s.length()-1] != '\\') @@ -224,6 +225,7 @@ int dir_add_watch(const char* const dir, intptr_t* const _reqnum) goto fail; } + // post a dummy kickoff packet; the IOCP polling code will "re"issue // the corresponding watch. this keeps the ReadDirectoryChangesW call // and directory <--> Watch association code in one place. @@ -245,7 +247,15 @@ fail: int dir_cancel_watch(const intptr_t reqnum) { + if(reqnum < 0) + return -1; + Watch* w = watches[reqnum]; + if(!w) + { + debug_warn("dir_cancel_watch: watches[reqnum] invalid"); + return -1; + } // contrary to dox, the RDC IOs do not issue a completion notification. // no packet was received on the IOCP while or after cancelling in a test.