unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#19292: 24.3; [PATCH] erc-server-ping-timer-alist now has at most one timer per buffer
@ 2014-12-06 22:49 Dima Kogan
       [not found] ` <handler.19292.B.1417906179802.ack@debbugs.gnu.org>
  2015-12-27 20:19 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 3+ messages in thread
From: Dima Kogan @ 2014-12-06 22:49 UTC (permalink / raw)
  To: 19292

[-- Attachment #1: Type: text/plain, Size: 428 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-erc-server-ping-timer-alist-now-has-at-most-one-time.patch --]
[-- Type: text/x-diff, Size: 2138 bytes --]

From 421c00345c3407fff7044092c458316c6da870a6 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#19292: 24.3; [PATCH] erc-server-ping-timer-alist now has at most one timer per buffer
       [not found] ` <handler.19292.B.1417906179802.ack@debbugs.gnu.org>
@ 2015-02-15 20:03   ` Dima Kogan
  0 siblings, 0 replies; 3+ messages in thread
From: Dima Kogan @ 2015-02-15 20:03 UTC (permalink / raw)
  To: 19292

Hi. This is a gentle ping. The attached patch made ERC usable for me,
and it would be great if it was merged. The added code is simply a
safety check.

Thanks





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#19292: 24.3; [PATCH] erc-server-ping-timer-alist now has at most one timer per buffer
  2014-12-06 22:49 bug#19292: 24.3; [PATCH] erc-server-ping-timer-alist now has at most one timer per buffer Dima Kogan
       [not found] ` <handler.19292.B.1417906179802.ack@debbugs.gnu.org>
@ 2015-12-27 20:19 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2015-12-27 20:19 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 19292

Dima Kogan <dima@secretsauce.net> writes:

> 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.

Thanks; applied to Emacs 25.1.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-27 20:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-06 22:49 bug#19292: 24.3; [PATCH] erc-server-ping-timer-alist now has at most one timer per buffer Dima Kogan
     [not found] ` <handler.19292.B.1417906179802.ack@debbugs.gnu.org>
2015-02-15 20:03   ` Dima Kogan
2015-12-27 20:19 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).