[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 37bccf19ca: Handle connection errors in rcirc-keepalive
From: |
Philip Kaludercic |
Subject: |
master 37bccf19ca: Handle connection errors in rcirc-keepalive |
Date: |
Sun, 17 Apr 2022 08:22:36 -0400 (EDT) |
branch: master
commit 37bccf19caa6ad245bb4c8adacfb1a1d203d1d2d
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Handle connection errors in rcirc-keepalive
* rcirc.el (rcirc-reconnect-delay): Declare variable before it is
defined.
(rcirc-keepalive): Handle rcirc-closed-connection, respecting
rcirc-reconnect-delay.
(rcirc-closed-connection): Add new error type.
(rcirc-send-string): Throw rcirc-closed-connection instead of a
generic error.
---
lisp/net/rcirc.el | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 5fe65cc7b3..f34be6daf3 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -771,18 +771,26 @@ SERVER-PLIST is the property list for the server."
(yes-or-no-p "Encrypt connection?"))
'tls 'plain))
+(defvar rcirc-reconnect-delay)
(defun rcirc-keepalive ()
"Send keep alive pings to active rcirc processes.
Kill processes that have not received a server message since the
last ping."
(if (rcirc-process-list)
(mapc (lambda (process)
- (with-rcirc-process-buffer process
- (when (not rcirc-connecting)
- (rcirc-send-ctcp process
- rcirc-nick
- (format "KEEPALIVE %f"
- (float-time))))))
+ (with-rcirc-process-buffer process
+ (when (not rcirc-connecting)
+ (condition-case nil
+ (rcirc-send-ctcp process
+ rcirc-nick
+ (format "KEEPALIVE %f"
+ (float-time)))
+ (rcirc-closed-connection
+ (if (zerop rcirc-reconnect-delay)
+ (message "rcirc: Connection to %s closed"
+ (process-name process))
+ (rcirc-reconnect process))
+ (message ""))))))
(rcirc-process-list))
;; no processes, clean up timer
(when (timerp rcirc-keepalive-timer)
@@ -1136,6 +1144,8 @@ used as the message body."
"Check if PROCESS is open or running."
(memq (process-status process) '(run open)))
+(define-error 'rcirc-closed-connection "Network connection not open")
+
(defun rcirc-send-string (process &rest parts)
"Send PROCESS a PARTS plus a newline.
PARTS may contain a `:' symbol, to designate that the next string
@@ -1153,8 +1163,7 @@ element in PARTS is a list, append it to PARTS."
rcirc-encode-coding-system)
"\n")))
(unless (rcirc--connection-open-p process)
- (error "Network connection to %s is not open"
- (process-name process)))
+ (signal 'rcirc-closed-connection process))
(rcirc-debug process string)
(process-send-string process string)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 37bccf19ca: Handle connection errors in rcirc-keepalive,
Philip Kaludercic <=