[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Erc-commit] [commit][master] Be more careful about the current buffer i
From: |
mwolson |
Subject: |
[Erc-commit] [commit][master] Be more careful about the current buffer in erc-process-sentinel-1 |
Date: |
Sun, 14 Oct 2007 00:49:20 -0400 |
commit 590370e8ff611b30868ba0e73127425729275abf
Author: Michael W. Olson <address@hidden>
Date: Mon Aug 13 23:34:18 2007 -0400
Be more careful about the current buffer in erc-process-sentinel-1
* erc-backend.el (erc-process-sentinel-1): Take server buffer as an
argument, so that we can make sure that it is current. If it is
deleted during a reconnect attempt, stop trying to reconnect.
(erc-process-sentinel): Pass buffer to erc-process-sentinel-1.
diff --git a/ChangeLog b/ChangeLog
index 50b8dd4..b0dce79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,10 @@
buffer is not an ERC buffer, give an error. This fixes a bug when
/reconnect is run from a channel buffer whose server buffer has
been deleted. Thanks to jbms for the report.
+ (erc-process-sentinel-1): Take server buffer as an argument, so
+ that we can make sure that it is current. If it is deleted during
+ a reconnect attempt, stop trying to reconnect.
+ (erc-process-sentinel): Pass buffer to erc-process-sentinel-1.
* erc.el (erc-command-no-process-p): Fix bug: the return value of
erc-extract-command-from-line is a list rather than a single
diff --git a/erc-backend.el b/erc-backend.el
index 75bef89..463bffa 100644
--- a/erc-backend.el
+++ b/erc-backend.el
@@ -610,39 +610,42 @@ EVENT is the message received from the closed connection
process."
;; open-network-stream-nowait error for connection refused
(not (string-match "^failed with code 111" event)))))
-(defun erc-process-sentinel-1 (event)
+(defun erc-process-sentinel-1 (event buffer)
"Called when `erc-process-sentinel' has decided that we're disconnecting.
Determine whether user has quit or whether erc has been terminated.
Conditionally try to reconnect and take appropriate action."
- (if erc-server-quitting
- ;; normal quit
- (progn
- (erc-display-message nil 'error (current-buffer) 'finished)
- (when erc-kill-server-buffer-on-quit
- (set-buffer-modified-p nil)
- (kill-buffer (current-buffer))))
- ;; unexpected disconnect
- (let ((again t))
- (while again
- (setq again nil)
- (erc-display-message nil 'error (current-buffer)
- (if (erc-server-reconnect-p event)
- 'disconnected
- 'disconnected-noreconnect))
- (if (erc-server-reconnect-p event)
- (condition-case err
- (progn
- (setq erc-server-reconnecting nil)
- (erc-server-reconnect)
- (setq erc-server-reconnect-count 0))
- (error (when (integerp erc-server-reconnect-attempts)
- (setq erc-server-reconnect-count
- (1+ erc-server-reconnect-count))
- (sit-for erc-server-reconnect-timeout)
- (setq again t))))
- ;; terminate, do not reconnect
+ (with-current-buffer buffer
+ (if erc-server-quitting
+ ;; normal quit
+ (progn
+ (erc-display-message nil 'error (current-buffer) 'finished)
+ (when erc-kill-server-buffer-on-quit
+ (set-buffer-modified-p nil)
+ (kill-buffer (current-buffer))))
+ ;; unexpected disconnect
+ (let ((again t))
+ (while again
+ (setq again nil)
(erc-display-message nil 'error (current-buffer)
- 'terminated ?e event))))))
+ (if (erc-server-reconnect-p event)
+ 'disconnected
+ 'disconnected-noreconnect))
+ (if (erc-server-reconnect-p event)
+ (condition-case err
+ (progn
+ (setq erc-server-reconnecting nil)
+ (erc-server-reconnect)
+ (setq erc-server-reconnect-count 0))
+ (error (when (buffer-live-p buffer)
+ (set-buffer buffer)
+ (when (integerp erc-server-reconnect-attempts)
+ (setq erc-server-reconnect-count
+ (1+ erc-server-reconnect-count))
+ (sit-for erc-server-reconnect-timeout)
+ (setq again t)))))
+ ;; terminate, do not reconnect
+ (erc-display-message nil 'error (current-buffer)
+ 'terminated ?e event)))))))
(defun erc-process-sentinel (cproc event)
"Sentinel function for ERC process."
@@ -669,7 +672,7 @@ Conditionally try to reconnect and take appropriate action."
(delete-region (point) (point-max))
;; Decide what to do with the buffer
;; Restart if disconnected
- (erc-process-sentinel-1 event)
+ (erc-process-sentinel-1 event buf)
;; Make sure we don't write to the buffer if it has been
;; killed
(when (buffer-live-p buf)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Erc-commit] [commit][master] Be more careful about the current buffer in erc-process-sentinel-1,
mwolson <=