diff options
| author | F. Jason Park | 2021-11-06 03:15:24 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-11-06 03:15:24 +0100 |
| commit | 58deb30fd0df5aeed3303b2dfd53be171fdd5f81 (patch) | |
| tree | 25795b92bca553563296a08b58fbaa0833c6c2c0 /lisp/erc | |
| parent | 4d656ea5ff7ba79315af42e159254867bfd157ad (diff) | |
| download | emacs-58deb30fd0df5aeed3303b2dfd53be171fdd5f81.tar.gz emacs-58deb30fd0df5aeed3303b2dfd53be171fdd5f81.zip | |
Normalize usage of variable erc-server-reconnecting
* lisp/erc/erc-backend.el (erc-server-reconnecting-p):
Don't consider erc-server-reconnecting when rendering verdict.
(erc-process-sentinel-2): ensure local variable
erc-server-reconnecting is t when timers are scheduled or running and
trying to reconnect, and nil otherwise, including after no retries
remain. Previously, its use and meaning in erc-backend were convoluted
and conflicted with its use in erc-cmd-RECONNECT (bug#50007).
Diffstat (limited to 'lisp/erc')
| -rw-r--r-- | lisp/erc/erc-backend.el | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index a26cb740a73..6e5a768b70f 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el | |||
| @@ -197,8 +197,7 @@ active, use the `erc-server-process-alive' function instead.") | |||
| 197 | "Non-nil if the user requests a quit.") | 197 | "Non-nil if the user requests a quit.") |
| 198 | 198 | ||
| 199 | (defvar-local erc-server-reconnecting nil | 199 | (defvar-local erc-server-reconnecting nil |
| 200 | "Non-nil if the user requests an explicit reconnect, and the | 200 | "Non-nil if reconnecting or scheduled to.") |
| 201 | current IRC process is still alive.") | ||
| 202 | 201 | ||
| 203 | (defvar-local erc-server-timed-out nil | 202 | (defvar-local erc-server-timed-out nil |
| 204 | "Non-nil if the IRC server failed to respond to a ping.") | 203 | "Non-nil if the IRC server failed to respond to a ping.") |
| @@ -616,36 +615,34 @@ Make sure you are in an ERC buffer when running this." | |||
| 616 | (erc-log-irc-protocol line nil) | 615 | (erc-log-irc-protocol line nil) |
| 617 | (erc-parse-server-response process line))))))) | 616 | (erc-parse-server-response process line))))))) |
| 618 | 617 | ||
| 619 | (define-inline erc-server-reconnect-p (event) | 618 | (defun erc--server-reconnect-p (event) |
| 620 | "Return non-nil if ERC should attempt to reconnect automatically. | 619 | "Return non-nil if ERC should attempt to reconnect automatically. |
| 621 | EVENT is the message received from the closed connection process." | 620 | EVENT is the message received from the closed connection process." |
| 622 | (inline-letevals (event) | 621 | (and erc-server-auto-reconnect |
| 623 | (inline-quote | 622 | (not erc-server-banned) |
| 624 | (or erc-server-reconnecting | 623 | ;; make sure we don't infinitely try to reconnect, unless the |
| 625 | (and erc-server-auto-reconnect | 624 | ;; user wants that |
| 626 | (not erc-server-banned) | 625 | (or (eq erc-server-reconnect-attempts t) |
| 627 | ;; make sure we don't infinitely try to reconnect, unless the | 626 | (and (integerp erc-server-reconnect-attempts) |
| 628 | ;; user wants that | 627 | (< erc-server-reconnect-count |
| 629 | (or (eq erc-server-reconnect-attempts t) | 628 | erc-server-reconnect-attempts))) |
| 630 | (and (integerp erc-server-reconnect-attempts) | 629 | (or erc-server-timed-out |
| 631 | (< erc-server-reconnect-count | 630 | (not (string-match "^deleted" event))) |
| 632 | erc-server-reconnect-attempts))) | 631 | ;; open-network-stream-nowait error for connection refused |
| 633 | (or erc-server-timed-out | 632 | (if (string-match "^failed with code 111" event) 'nonblocking t))) |
| 634 | (not (string-match "^deleted" ,event))) | ||
| 635 | ;; open-network-stream-nowait error for connection refused | ||
| 636 | (if (string-match "^failed with code 111" ,event) 'nonblocking t)))))) | ||
| 637 | 633 | ||
| 638 | (defun erc-process-sentinel-2 (event buffer) | 634 | (defun erc-process-sentinel-2 (event buffer) |
| 639 | "Called when `erc-process-sentinel-1' has detected an unexpected disconnect." | 635 | "Called when `erc-process-sentinel-1' has detected an unexpected disconnect." |
| 640 | (if (not (buffer-live-p buffer)) | 636 | (if (not (buffer-live-p buffer)) |
| 641 | (erc-update-mode-line) | 637 | (erc-update-mode-line) |
| 642 | (with-current-buffer buffer | 638 | (with-current-buffer buffer |
| 643 | (let ((reconnect-p (erc-server-reconnect-p event)) message delay) | 639 | (let ((reconnect-p (erc--server-reconnect-p event)) message delay) |
| 644 | (setq message (if reconnect-p 'disconnected 'disconnected-noreconnect)) | 640 | (setq message (if reconnect-p 'disconnected 'disconnected-noreconnect)) |
| 645 | (erc-display-message nil 'error (current-buffer) message) | 641 | (erc-display-message nil 'error (current-buffer) message) |
| 646 | (if (not reconnect-p) | 642 | (if (not reconnect-p) |
| 647 | ;; terminate, do not reconnect | 643 | ;; terminate, do not reconnect |
| 648 | (progn | 644 | (progn |
| 645 | (setq erc-server-reconnecting nil) | ||
| 649 | (erc-display-message nil 'error (current-buffer) | 646 | (erc-display-message nil 'error (current-buffer) |
| 650 | 'terminated ?e event) | 647 | 'terminated ?e event) |
| 651 | ;; Update mode line indicators | 648 | ;; Update mode line indicators |
| @@ -654,7 +651,7 @@ EVENT is the message received from the closed connection process." | |||
| 654 | ;; reconnect | 651 | ;; reconnect |
| 655 | (condition-case nil | 652 | (condition-case nil |
| 656 | (progn | 653 | (progn |
| 657 | (setq erc-server-reconnecting nil | 654 | (setq erc-server-reconnecting t |
| 658 | erc-server-reconnect-count (1+ erc-server-reconnect-count)) | 655 | erc-server-reconnect-count (1+ erc-server-reconnect-count)) |
| 659 | (setq delay erc-server-reconnect-timeout) | 656 | (setq delay erc-server-reconnect-timeout) |
| 660 | (run-at-time delay nil | 657 | (run-at-time delay nil |