Avoid a race condition in url-queue-kill-job
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 20 Feb 2012 12:12:48 +0000 (13:12 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 20 Feb 2012 12:12:48 +0000 (13:12 +0100)
* url-queue.el (url-queue-kill-job): Delete the process sentinel
before killing the process to avoid a race condition between the
two processes killing off the process buffer.

lisp/url/ChangeLog
lisp/url/url-queue.el

index e57b5ec..55aa919 100644 (file)
@@ -1,5 +1,9 @@
 2012-02-20  Lars Ingebrigtsen  <larsi@gnus.org>
 
+       * url-queue.el (url-queue-kill-job): Delete the process sentinel
+       before killing the process to avoid a race condition between the
+       two processes killing off the process buffer.
+
        * url.el (url-retrieve-internal): Warn about file errors when
        pruning the cache instead of bugging out (bug#10831).
 
index 6456d44..6e4cedd 100644 (file)
@@ -152,9 +152,11 @@ The variable `url-queue-timeout' sets a timeout."
 
 (defun url-queue-kill-job (job)
   (when (bufferp (url-queue-buffer job))
-    (while (get-buffer-process (url-queue-buffer job))
-      (ignore-errors
-       (delete-process (get-buffer-process (url-queue-buffer job)))))
+    (let (process)
+      (while (setq process (get-buffer-process (url-queue-buffer job)))
+       (set-process-sentinel process 'ignore)
+       (ignore-errors
+         (delete-process process))))
     (ignore-errors
       (kill-buffer (url-queue-buffer job)))))