diff options
author | Dima Kogan <dima@secretsauce.net> | 2015-12-27 21:19:13 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2015-12-27 21:19:13 +0100 |
commit | 2cd894dc348b4872d7beb10275387c30027c8f26 (patch) | |
tree | 0b2b1f6e761d204cc9300659a58111cf6ea63fe8 | |
parent | 85c1843f65f0fd82ed6c1df92b6a9a5113e51b1e (diff) | |
download | emacs-2cd894dc348b4872d7beb10275387c30027c8f26.tar.gz |
Ensure that we don't have several timers in erc
* lisp/erc/erc-backend.el (erc-server-setup-periodical-ping): Checks
for existing timers in the alist before adding new ones. If a
timer already exists, it is cancelled and
overwritten. (bug#19292).
-rw-r--r-- | lisp/erc/erc-backend.el | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index b52c8f5454f..daaa1b0428a 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -493,9 +493,19 @@ The current buffer is given by BUFFER." 4 erc-server-send-ping-interval #'erc-server-send-ping buffer)) - (setq erc-server-ping-timer-alist (cons (cons buffer - erc-server-ping-handler) - erc-server-ping-timer-alist))))) + + ;; I check the timer alist for an existing timer. If one exists, + ;; I get rid of it + (let ((timer-tuple (assq buffer erc-server-ping-timer-alist))) + (if timer-tuple + ;; this buffer already has a timer. Cancel it and set the new one + (progn + (erc-cancel-timer (cdr timer-tuple)) + (setf (cdr (assq buffer erc-server-ping-timer-alist)) erc-server-ping-handler)) + + ;; no existing timer for this buffer. Add new one + (add-to-list 'erc-server-ping-timer-alist + (cons buffer erc-server-ping-handler))))))) (defun erc-server-process-alive (&optional buffer) "Return non-nil when BUFFER has an `erc-server-process' open or running." |