aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2012-10-18 20:13:03 +0200
committerEli Zaretskii2012-10-18 20:13:03 +0200
commit9e1821d3a2350a87de85d19208a63cfcd27d7b50 (patch)
treec31fe3b8f28fe68e7a0712aad64987f2d6fdd4ed /src
parentd884121be07ea5e47ad7c763d5370a6def7f9bd8 (diff)
downloademacs-9e1821d3a2350a87de85d19208a63cfcd27d7b50.tar.gz
emacs-9e1821d3a2350a87de85d19208a63cfcd27d7b50.zip
Don't call xfree from the watcher thread. Do it only in remove_watch.
Diffstat (limited to 'src')
-rw-r--r--src/w32notify.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/w32notify.c b/src/w32notify.c
index 9fcd15e7f8f..afa03498ff3 100644
--- a/src/w32notify.c
+++ b/src/w32notify.c
@@ -214,14 +214,10 @@ watch_completion (DWORD status, DWORD bytes_ret, OVERLAPPED *io_info)
214 The directory handle is already closed. We should clean up 214 The directory handle is already closed. We should clean up
215 and exit, signalling to the thread worker routine not to 215 and exit, signalling to the thread worker routine not to
216 issue another call to ReadDirectoryChangesW. Note that we 216 issue another call to ReadDirectoryChangesW. Note that we
217 don't free the dirwatch object itself; this is done by the 217 don't free the dirwatch object itself nor the memory consumed
218 main thread in remove_watch. */ 218 by its buffers; this is done by the main thread in
219 xfree (dirwatch->buf); 219 remove_watch. Calling malloc/free from a thread other than
220 dirwatch->buf = NULL; 220 the main thread is a no-no. */
221 xfree (dirwatch->io_info);
222 dirwatch->io_info = NULL;
223 xfree (dirwatch->watchee);
224 dirwatch->watchee = NULL;
225 dirwatch->dir = NULL; 221 dirwatch->dir = NULL;
226 dirwatch->terminate = 1; 222 dirwatch->terminate = 1;
227 } 223 }
@@ -254,19 +250,15 @@ watch_worker (LPVOID arg)
254 { 250 {
255 DebPrint (("watch_worker, abnormal exit: %lu\n", GetLastError ())); 251 DebPrint (("watch_worker, abnormal exit: %lu\n", GetLastError ()));
256 /* We cannot remove the dirwatch object from watch_list, 252 /* We cannot remove the dirwatch object from watch_list,
257 because we are in a separate thread. So we free and 253 because we are in a separate thread. For the same
258 zero out all the pointers in the object, but do not 254 reason, we also cannot free memory consumed by the
259 free the object itself. We also don't touch the 255 buffers allocated for the dirwatch object. So we close
260 signature. This way, remove_watch can still identify 256 the directory handle, but do not free the object itself
261 the object, remove it, and free its memory. */ 257 or its buffers. We also don't touch the signature.
262 xfree (dirwatch->buf); 258 This way, remove_watch can still identify the object,
263 dirwatch->buf = NULL; 259 remove it, and free its memory. */
264 xfree (dirwatch->io_info);
265 dirwatch->io_info = NULL;
266 CloseHandle (dirwatch->dir); 260 CloseHandle (dirwatch->dir);
267 dirwatch->dir = NULL; 261 dirwatch->dir = NULL;
268 xfree (dirwatch->watchee);
269 dirwatch->watchee = NULL;
270 return 1; 262 return 1;
271 } 263 }
272 } 264 }