# HG changeset patch # User Stefan Monnier # Date 1113830383 0 # Node ID 68114d546e484065252122bd9f5a3ea3c45ff0fc # Parent cacf55df1896c3779fcbc6eba2430a2617e185e3 (url-retrieve-synchronously): Work around the fact that url-http sometimes doesn't call the callback. diff -r cacf55df1896 -r 68114d546e48 lisp/url/ChangeLog --- a/lisp/url/ChangeLog Mon Apr 18 11:34:46 2005 +0000 +++ b/lisp/url/ChangeLog Mon Apr 18 13:19:43 2005 +0000 @@ -1,3 +1,8 @@ +2005-04-18 Stefan Monnier + + * url.el (url-retrieve-synchronously): Work around the fact that + url-http sometimes doesn't call the callback. + 2005-04-04 Lute Kamstra * url-handlers.el (url-handler-mode): Specify :group. diff -r cacf55df1896 -r 68114d546e48 lisp/url/url.el --- a/lisp/url/url.el Mon Apr 18 11:34:46 2005 +0000 +++ b/lisp/url/url.el Mon Apr 18 13:19:43 2005 +0000 @@ -180,15 +180,23 @@ (url-debug 'retrieval "Spinning in url-retrieve-synchronously: %S (%S)" retrieval-done asynch-buffer) - ;; We used to use `sit-for' here, but in some cases it wouldn't - ;; work because apparently pending keyboard input would always - ;; interrupt it before it got a chance to handle process input. - ;; `sleep-for' was tried but it lead to other forms of - ;; hanging. --Stef - (unless (accept-process-output proc) - ;; accept-process-output returned nil, maybe because the process - ;; exited (and may have been replaced with another). - (setq proc (get-buffer-process asynch-buffer))))) + (if (memq (process-status proc) '(closed exit signal failed)) + ;; FIXME: It's not clear whether url-retrieve's callback is + ;; guaranteed to be called or not. It seems that url-http + ;; decides sometimes consciously not to call it, so it's not + ;; clear that it's a bug, but even if we need to decide how + ;; url-http can then warn us that the download has completed. + ;; In the mean time, we use this here workaround. + (setq retrieval-done t) + ;; We used to use `sit-for' here, but in some cases it wouldn't + ;; work because apparently pending keyboard input would always + ;; interrupt it before it got a chance to handle process input. + ;; `sleep-for' was tried but it lead to other forms of + ;; hanging. --Stef + (unless (accept-process-output proc) + ;; accept-process-output returned nil, maybe because the process + ;; exited (and may have been replaced with another). + (setq proc (get-buffer-process asynch-buffer)))))) asynch-buffer))) (defun url-mm-callback (&rest ignored)