summaryrefslogtreecommitdiff
path: root/lisp/jsonrpc.el
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2018-08-11 14:18:17 +0100
committerJoão Távora <joaotavora@gmail.com>2018-08-11 14:57:01 +0100
commitc580443325a3d071625185876a8f28e04793c625 (patch)
treefeabd1f92982bff0850fe9e855da239cdee82db7 /lisp/jsonrpc.el
parent914b0300bcca8ac016b85df54ed36c98d07c74a7 (diff)
downloademacs-c580443325a3d071625185876a8f28e04793c625.tar.gz
Make jsonrpc-shutdown a noop if process isn't running
* lisp/jsonrpc.el (Version): Bump to 1.0.4 (jsonrpc-shutdown): Noop if server isn't running.
Diffstat (limited to 'lisp/jsonrpc.el')
-rw-r--r--lisp/jsonrpc.el23
1 files changed, 13 insertions, 10 deletions
diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el
index f3e0982139c..b41c30c5162 100644
--- a/lisp/jsonrpc.el
+++ b/lisp/jsonrpc.el
@@ -6,7 +6,7 @@
;; Maintainer: João Távora <joaotavora@gmail.com>
;; Keywords: processes, languages, extensions
;; Package-Requires: ((emacs "25.2"))
-;; Version: 1.0.3
+;; Version: 1.0.4
;; This is an Elpa :core package. Don't use functionality that is not
;; compatible with Emacs 25.2.
@@ -412,15 +412,18 @@ connection object, called when the process dies .")
(process-live-p (jsonrpc--process conn)))
(cl-defmethod jsonrpc-shutdown ((conn jsonrpc-process-connection))
- "Shutdown the JSONRPC connection CONN."
- (cl-loop
- with proc = (jsonrpc--process conn)
- do
- (delete-process proc)
- (accept-process-output nil 0.1)
- while (not (process-get proc 'jsonrpc-sentinel-done))
- do (jsonrpc--warn
- "Sentinel for %s still hasn't run, deleting it!" proc)))
+ "Wait for JSONRPC connection CONN to shutdown and return t.
+If the server wasn't running, do nothing and return nil."
+ (when (jsonrpc-running-p conn)
+ (cl-loop
+ with proc = (jsonrpc--process conn)
+ do
+ (delete-process proc)
+ (accept-process-output nil 0.1)
+ while (not (process-get proc 'jsonrpc-sentinel-done))
+ do (jsonrpc--warn
+ "Sentinel for %s still hasn't run, deleting it!" proc)
+ finally return t)))
(defun jsonrpc-stderr-buffer (conn)
"Get CONN's standard error buffer, if any."