MINOR: peers: Use a dedicated reconnect timeout when stopping the local peer

When a process is stopped or reload, a dedicated reconnect timeout is now
used. For now, this timeout is not used because the current code retries
immediately to reconnect to perform the local synchronization with the new
local peer, if any.

This patch is required to fix the issue #1799. It should be backported as
far as 2.0 with next fixes.

(cherry picked from commit ab4b094055fee113e91149426035c9ff7b35b2b0)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 810e8f2fcd514ac9c62575e0b0c1fca70b503918)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 0bfdc84cfd9add927ec729184eaf636c6ffb19e6)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/peers.c b/src/peers.c
index 5c26751..024b0ee 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -98,6 +98,7 @@
 
 #define PEER_RESYNC_TIMEOUT         5000 /* 5 seconds */
 #define PEER_RECONNECT_TIMEOUT      5000 /* 5 seconds */
+#define PEER_LOCAL_RECONNECT_TIMEOUT 500 /* 500ms */
 #define PEER_HEARTBEAT_TIMEOUT      3000 /* 3 seconds */
 
 /* flags for "show peers" */
@@ -2878,7 +2879,7 @@
 	struct stream *s;
 
 	peer->new_conn++;
-	peer->reconnect = tick_add(now_ms, MS_TO_TICKS(PEER_RECONNECT_TIMEOUT));
+	peer->reconnect = tick_add(now_ms, (stopping ? MS_TO_TICKS(PEER_LOCAL_RECONNECT_TIMEOUT) : MS_TO_TICKS(PEER_RECONNECT_TIMEOUT)));
 	peer->heartbeat = TICK_ETERNITY;
 	peer->statuscode = PEER_SESS_SC_CONNECTCODE;
 	peer->last_hdshk = now_ms;