]> granicus.if.org Git - ngircd/commitdiff
Make server reconnect time a little bit more random
authorAlexander Barton <alex@barton.de>
Sun, 28 Oct 2012 19:19:57 +0000 (20:19 +0100)
committerAlexander Barton <alex@barton.de>
Mon, 29 Oct 2012 10:33:49 +0000 (11:33 +0100)
Add randomly up to 15 seconds to the reconnect delay for outgoing server
links when the connection has been "short" and therefore the "ConnectRetry"
delay is being enforced.

This should make it even more unlikely that two servers deadlock each
other when both are trying to connect to the other one at the same time,
for example in test environments.

src/ngircd/conf.c

index 6a7f63393c6f7177f054b991e72a15009cf6fa1c..815251297eea9da27f2db6d3cf0e7fa91433bb26 100644 (file)
@@ -481,8 +481,12 @@ Conf_UnsetServer( CONN_ID Idx )
                                 * require the next attempt to be delayed. */
                                Conf_Server[i].lasttry =
                                        t - Conf_ConnectRetry + RECONNECT_DELAY;
-                       } else
-                               Conf_Server[i].lasttry = t;
+                       } else {
+                               /* "Short" connection, enforce "ConnectRetry"
+                                * but randomize it a little bit: 15 seconds. */
+                               Conf_Server[i].lasttry =
+                                       t + rand() / (RAND_MAX / 15);
+                       }
                }
        }
 }