Subject: bug#5650: Issue with the patch

From: Thomas Riccardi <[email-masked]>
Date: Sun, 25 Apr 2010 22:39:14 +0200

The patch works for me (even if there is still a small freeze during
about 1 second at the connection if the server doesn't answer), but
creates an issue with the auto reconnect feature.

It happens when the server doesn't answer the connection request (tested
with a DROP on packets coming from it with iptables).

The patch makes the function erc-server-connect to return even if the
connection is not ready. Then erc-open and erc-server-reconnect do the
same.

Finally, in erc-process-sentinel-2, there is no error executing
erc-server-reconnect, thus erc-server-reconnect-count is never
incremented and is even reset.

I made a patch that increments erc-server-reconnect-count before calling
erc-server-reconnect instead, and resets it only when the connection is
really ready, that is, in erc-connection-established.
diff --git a/.emacs.d/erc-5.3/erc-backend.el b/.emacs.d/erc-5.3/erc-backend.el
index 70ce789..928770e 100644
--- a/.emacs.d/erc-5.3/erc-backend.el
+++ b/.emacs.d/erc-5.3/erc-backend.el
@@ -618,13 +618,11 @@ EVENT is the message received from the closed connection process."
           (condition-case err
               (progn
                 (setq erc-server-reconnecting nil)
-                (erc-server-reconnect)
-                (setq erc-server-reconnect-count 0))
+                (setq erc-server-reconnect-count (1+ erc-server-reconnect-count))
+                (erc-server-reconnect))
             (error (when (buffer-live-p buffer)
                      (set-buffer buffer)
-                     (if (integerp erc-server-reconnect-attempts)
-                         (setq erc-server-reconnect-count
-                               (1+ erc-server-reconnect-count))
+                     (unless (integerp erc-server-reconnect-attempts)
                        (message "%s ... %s"
                                 "Reconnecting until we succeed"
                                 "kill the ERC server buffer to stop"))
diff --git a/.emacs.d/erc-5.3/erc.el b/.emacs.d/erc-5.3/erc.el
index 9aa5e8b..802ae66 100644
--- a/.emacs.d/erc-5.3/erc.el
+++ b/.emacs.d/erc-5.3/erc.el
@@ -4267,6 +4267,7 @@ Set user modes and run `erc-after-connect' hook."
 	    (nick (car (erc-response.command-args parsed)))
 	    (buffer (process-buffer proc)))
 	(setq erc-server-connected t)
+	(setq erc-server-reconnect-count 0)
 	(erc-update-mode-line)
 	(erc-set-initial-user-mode nick buffer)
 	(erc-server-setup-periodical-ping buffer)