[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot c417eb4 009/139: Cancel timeouts when process die
From: |
João Távora |
Subject: |
[elpa] externals/eglot c417eb4 009/139: Cancel timeouts when process dies unexpectedly |
Date: |
Mon, 14 May 2018 09:54:42 -0400 (EDT) |
branch: externals/eglot
commit c417eb4343ff76c18d323dd2a9861526940551f0
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Cancel timeouts when process dies unexpectedly
---
eglot.el | 53 ++++++++++++++++++++++++++++++++---------------------
1 file changed, 32 insertions(+), 21 deletions(-)
diff --git a/eglot.el b/eglot.el
index e3b288b..5699775 100644
--- a/eglot.el
+++ b/eglot.el
@@ -153,9 +153,16 @@
(with-current-buffer (process-buffer process)
(eglot--debug "Process state changed to %s" change)
(when (not (process-live-p process))
+ ;; Remember to cancel all timers
+ ;;
+ (maphash (lambda (id v)
+ (cl-destructuring-bind (_success _error timeout) v
+ (eglot--message "Cancelling timer for continuation %s" id)
+ (cancel-timer timeout)))
+ (eglot--pending-continuations process))
(cond ((process-get process 'eglot--moribund)
(eglot--message "Process exited with status %s"
- (process-exit-status process)))
+ (process-exit-status process)))
(t
(eglot--warn "Process unexpectedly changed to %s" change))))))
@@ -319,26 +326,30 @@
:method ,method
:params ,params))
(catch catch-tag
- (puthash id
- (list (if async-p
- success-fn
- (lambda (&rest args)
- (throw catch-tag (apply success-fn args))))
- (if async-p
- error-fn
- (lambda (&rest args)
- (throw catch-tag (apply error-fn args))))
- (run-with-timer 5 nil
- (if async-p
- timeout-fn
- (lambda ()
- (throw catch-tag (apply
timeout-fn))))))
- (eglot--pending-continuations process))
- (unless async-p
- (while t
- (unless (eq (process-status process) 'open)
- (eglot--error "Process %s died unexpectedly" process))
- (accept-process-output nil 0.01))))))
+ (let ((timeout-timer
+ (run-with-timer 5 nil
+ (if async-p
+ timeout-fn
+ (lambda ()
+ (throw catch-tag (apply timeout-fn)))))))
+ (puthash id
+ (list (if async-p
+ success-fn
+ (lambda (&rest args)
+ (throw catch-tag (apply success-fn args))))
+ (if async-p
+ error-fn
+ (lambda (&rest args)
+ (throw catch-tag (apply error-fn args))))
+ timeout-timer)
+ (eglot--pending-continuations process))
+ (unless async-p
+ (unwind-protect
+ (while t
+ (unless (process-live-p process)
+ (eglot--error "Process %s died unexpectedly" process))
+ (accept-process-output nil 0.01))
+ (cancel-timer timeout-timer)))))))
;;; Requests
- [elpa] branch externals/eglot created (now 4c0bfc3), João Távora, 2018/05/14
- [elpa] externals/eglot 3a8f9a1 002/139: Remove a couple of comments, João Távora, 2018/05/14
- [elpa] externals/eglot 72895ca 006/139: Handle notifications, João Távora, 2018/05/14
- [elpa] externals/eglot 0222e7e 007/139: Improve `eglot--current-process', João Távora, 2018/05/14
- [elpa] externals/eglot 2775dea 003/139: Rename eglot--continuations eglot--pending-continuations, João Távora, 2018/05/14
- [elpa] externals/eglot c417eb4 009/139: Cancel timeouts when process dies unexpectedly,
João Távora <=
- [elpa] externals/eglot 6f0a8df 008/139: Organize a bit, João Távora, 2018/05/14
- [elpa] externals/eglot c222c3b 019/139: Lay groundwork for uniform treatment of network connections, João Távora, 2018/05/14
- [elpa] externals/eglot 3489176 004/139: Add a mode-line construct and some minor fanciness, João Távora, 2018/05/14
- [elpa] externals/eglot dfab9a0 011/139: Experimental diagnostic overlays, João Távora, 2018/05/14
- [elpa] externals/eglot 16be2fc 020/139: Fix parser to accept multiple messages in one chunk, João Távora, 2018/05/14
- [elpa] externals/eglot 0ec7801 012/139: Simplify `eglot--protocol-initialize`, João Távora, 2018/05/14
- [elpa] externals/eglot 4f246b5 017/139: * eglot.el (eglot-mode-map): Move up before minor mode., João Távora, 2018/05/14
- [elpa] externals/eglot bc011d0 010/139: Minor cleanup, João Távora, 2018/05/14
- [elpa] externals/eglot e60c7fc 013/139: Overhaul async mechanism safety, João Távora, 2018/05/14
- [elpa] externals/eglot a4f99e0 005/139: Introduce and use `eglot--current-process-or-lose', João Távora, 2018/05/14