diff options
| author | Philip Kaludercic | 2022-04-17 14:21:14 +0200 |
|---|---|---|
| committer | Philip Kaludercic | 2022-04-17 14:22:25 +0200 |
| commit | 37bccf19caa6ad245bb4c8adacfb1a1d203d1d2d (patch) | |
| tree | cb0a3dba13d61e245c7de89cded97fd695766ad0 | |
| parent | 2136db067f4292d84553ebfddab30d88b862262e (diff) | |
| download | emacs-37bccf19caa6ad245bb4c8adacfb1a1d203d1d2d.tar.gz emacs-37bccf19caa6ad245bb4c8adacfb1a1d203d1d2d.zip | |
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.
| -rw-r--r-- | lisp/net/rcirc.el | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 5fe65cc7b3e..f34be6daf3f 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el | |||
| @@ -771,18 +771,26 @@ SERVER-PLIST is the property list for the server." | |||
| 771 | (yes-or-no-p "Encrypt connection?")) | 771 | (yes-or-no-p "Encrypt connection?")) |
| 772 | 'tls 'plain)) | 772 | 'tls 'plain)) |
| 773 | 773 | ||
| 774 | (defvar rcirc-reconnect-delay) | ||
| 774 | (defun rcirc-keepalive () | 775 | (defun rcirc-keepalive () |
| 775 | "Send keep alive pings to active rcirc processes. | 776 | "Send keep alive pings to active rcirc processes. |
| 776 | Kill processes that have not received a server message since the | 777 | Kill processes that have not received a server message since the |
| 777 | last ping." | 778 | last ping." |
| 778 | (if (rcirc-process-list) | 779 | (if (rcirc-process-list) |
| 779 | (mapc (lambda (process) | 780 | (mapc (lambda (process) |
| 780 | (with-rcirc-process-buffer process | 781 | (with-rcirc-process-buffer process |
| 781 | (when (not rcirc-connecting) | 782 | (when (not rcirc-connecting) |
| 782 | (rcirc-send-ctcp process | 783 | (condition-case nil |
| 783 | rcirc-nick | 784 | (rcirc-send-ctcp process |
| 784 | (format "KEEPALIVE %f" | 785 | rcirc-nick |
| 785 | (float-time)))))) | 786 | (format "KEEPALIVE %f" |
| 787 | (float-time))) | ||
| 788 | (rcirc-closed-connection | ||
| 789 | (if (zerop rcirc-reconnect-delay) | ||
| 790 | (message "rcirc: Connection to %s closed" | ||
| 791 | (process-name process)) | ||
| 792 | (rcirc-reconnect process)) | ||
| 793 | (message "")))))) | ||
| 786 | (rcirc-process-list)) | 794 | (rcirc-process-list)) |
| 787 | ;; no processes, clean up timer | 795 | ;; no processes, clean up timer |
| 788 | (when (timerp rcirc-keepalive-timer) | 796 | (when (timerp rcirc-keepalive-timer) |
| @@ -1136,6 +1144,8 @@ used as the message body." | |||
| 1136 | "Check if PROCESS is open or running." | 1144 | "Check if PROCESS is open or running." |
| 1137 | (memq (process-status process) '(run open))) | 1145 | (memq (process-status process) '(run open))) |
| 1138 | 1146 | ||
| 1147 | (define-error 'rcirc-closed-connection "Network connection not open") | ||
| 1148 | |||
| 1139 | (defun rcirc-send-string (process &rest parts) | 1149 | (defun rcirc-send-string (process &rest parts) |
| 1140 | "Send PROCESS a PARTS plus a newline. | 1150 | "Send PROCESS a PARTS plus a newline. |
| 1141 | PARTS may contain a `:' symbol, to designate that the next string | 1151 | 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." | |||
| 1153 | rcirc-encode-coding-system) | 1163 | rcirc-encode-coding-system) |
| 1154 | "\n"))) | 1164 | "\n"))) |
| 1155 | (unless (rcirc--connection-open-p process) | 1165 | (unless (rcirc--connection-open-p process) |
| 1156 | (error "Network connection to %s is not open" | 1166 | (signal 'rcirc-closed-connection process)) |
| 1157 | (process-name process))) | ||
| 1158 | (rcirc-debug process string) | 1167 | (rcirc-debug process string) |
| 1159 | (process-send-string process string))) | 1168 | (process-send-string process string))) |
| 1160 | 1169 | ||