diff options
| author | João Távora | 2018-12-16 16:55:09 +0000 |
|---|---|---|
| committer | João Távora | 2018-12-16 16:55:38 +0000 |
| commit | 2f65525774b6e7edf119db678c9eb78cbb84de6a (patch) | |
| tree | 5441cfec006b7db8f6511404a15e01e70164cbd3 | |
| parent | f74595aace4b1240402562b0073b06c170969327 (diff) | |
| download | emacs-2f65525774b6e7edf119db678c9eb78cbb84de6a.tar.gz emacs-2f65525774b6e7edf119db678c9eb78cbb84de6a.zip | |
Jsonrpc error handlers can now safely call jsonrpc-shutdown
Previously, if an error handler called jsonrpc-shutdown, and if that
error handler was being called from the process sentinel,
jsonrpc-shutdown would infloop waiting for jsonrpc-sentinel-done to be
set.
Rename the process property jsonrpc-sentinel-done to
jsonrpc-sentinel-cleanup-started, arrange for it to be set earlier
in the sentinel, and also check for it earlier in jsonrpc-shutdown.
* lisp/jsonrpc.el (Version): Bump to 1.0.7.
(jsonrpc--process-sentinel): Set jsonrpc-sentinel-cleanup-started
a bit earlier than previous jsonrpc-sentinel-done.
(jsonrpc-shutdown): Query jsonrpc-sentinel-cleanup-started
| -rw-r--r-- | lisp/jsonrpc.el | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el index 020d7f56cc4..af69aa4dfd5 100644 --- a/lisp/jsonrpc.el +++ b/lisp/jsonrpc.el | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | ;; Maintainer: João Távora <joaotavora@gmail.com> | 6 | ;; Maintainer: João Távora <joaotavora@gmail.com> |
| 7 | ;; Keywords: processes, languages, extensions | 7 | ;; Keywords: processes, languages, extensions |
| 8 | ;; Package-Requires: ((emacs "25.2")) | 8 | ;; Package-Requires: ((emacs "25.2")) |
| 9 | ;; Version: 1.0.6 | 9 | ;; Version: 1.0.7 |
| 10 | 10 | ||
| 11 | ;; This is an Elpa :core package. Don't use functionality that is not | 11 | ;; This is an Elpa :core package. Don't use functionality that is not |
| 12 | ;; compatible with Emacs 25.2. | 12 | ;; compatible with Emacs 25.2. |
| @@ -421,13 +421,13 @@ connection object, called when the process dies .") | |||
| 421 | With optional CLEANUP, kill any associated buffers. " | 421 | With optional CLEANUP, kill any associated buffers. " |
| 422 | (unwind-protect | 422 | (unwind-protect |
| 423 | (cl-loop | 423 | (cl-loop |
| 424 | with proc = (jsonrpc--process conn) | 424 | with proc = (jsonrpc--process conn) for i from 0 |
| 425 | while (not (process-get proc 'jsonrpc-sentinel-cleanup-started)) | ||
| 426 | unless (zerop i) do | ||
| 427 | (jsonrpc--warn "Sentinel for %s still hasn't run, deleting it!" proc) | ||
| 425 | do | 428 | do |
| 426 | (delete-process proc) | 429 | (delete-process proc) |
| 427 | (accept-process-output nil 0.1) | 430 | (accept-process-output nil 0.1)) |
| 428 | while (not (process-get proc 'jsonrpc-sentinel-done)) | ||
| 429 | do (jsonrpc--warn | ||
| 430 | "Sentinel for %s still hasn't run, deleting it!" proc)) | ||
| 431 | (when cleanup | 431 | (when cleanup |
| 432 | (kill-buffer (process-buffer (jsonrpc--process conn))) | 432 | (kill-buffer (process-buffer (jsonrpc--process conn))) |
| 433 | (kill-buffer (jsonrpc-stderr-buffer conn))))) | 433 | (kill-buffer (jsonrpc-stderr-buffer conn))))) |
| @@ -486,6 +486,7 @@ With optional CLEANUP, kill any associated buffers. " | |||
| 486 | (pcase-let ((`(,_success ,_error ,timeout) triplet)) | 486 | (pcase-let ((`(,_success ,_error ,timeout) triplet)) |
| 487 | (when timeout (cancel-timer timeout)))) | 487 | (when timeout (cancel-timer timeout)))) |
| 488 | (jsonrpc--request-continuations connection)) | 488 | (jsonrpc--request-continuations connection)) |
| 489 | (process-put proc 'jsonrpc-sentinel-cleanup-started t) | ||
| 489 | (unwind-protect | 490 | (unwind-protect |
| 490 | ;; Call all outstanding error handlers | 491 | ;; Call all outstanding error handlers |
| 491 | (maphash (lambda (_id triplet) | 492 | (maphash (lambda (_id triplet) |
| @@ -493,7 +494,6 @@ With optional CLEANUP, kill any associated buffers. " | |||
| 493 | (funcall error '(:code -1 :message "Server died")))) | 494 | (funcall error '(:code -1 :message "Server died")))) |
| 494 | (jsonrpc--request-continuations connection)) | 495 | (jsonrpc--request-continuations connection)) |
| 495 | (jsonrpc--message "Server exited with status %s" (process-exit-status proc)) | 496 | (jsonrpc--message "Server exited with status %s" (process-exit-status proc)) |
| 496 | (process-put proc 'jsonrpc-sentinel-done t) | ||
| 497 | (delete-process proc) | 497 | (delete-process proc) |
| 498 | (funcall (jsonrpc--on-shutdown connection) connection))))) | 498 | (funcall (jsonrpc--on-shutdown connection) connection))))) |
| 499 | 499 | ||