GNU bug report logs -
#19292
24.3; [PATCH] erc-server-ping-timer-alist now has at most one timer per buffer
Previous Next
Reported by: Dima Kogan <dima <at> secretsauce.net>
Date: Sat, 6 Dec 2014 22:50:01 UTC
Severity: normal
Tags: fixed, patch
Found in version 24.3
Fixed in version 25.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
This alist was meant to map buffers to timers, but the "push" function
was not checking for already-existing timers. This was causing a
flood of PINGs being queued (because more than one timer was inserting
those), and the flood-control logic would block those from going
through quickly.
This patch checks for existing timers in the alist before adding new
ones. If a timer already exists, it is cancelled and overwritten.
[0001-erc-server-ping-timer-alist-now-has-at-most-one-time.patch (text/x-diff, inline)]
From 421c00345c3407fff7044092c458316c6da870a6 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima <at> secretsauce.net>
Date: Sat, 6 Dec 2014 14:46:51 -0800
Subject: [PATCH] erc-server-ping-timer-alist now has at most one timer per
buffer
This alist was meant to map buffers to timers, but the "push" function
was not checking for already-existing timers. This was causing a
flood of PINGs being queued (because more than one timer was inserting
those), and the flood-control logic would block those from going
through quickly.
This patch checks for existing timers in the alist before adding new
ones. If a timer already exists, it is cancelled and overwritten.
---
lisp/erc/erc-backend.el | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index fb22f58..bedb20f 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."
--
2.0.0
This bug report was last modified 9 years and 146 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.