]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: peers: Wrong "new_conn" value for "show peers" CLI command.
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 18 Jan 2021 14:14:39 +0000 (15:14 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 19 Jan 2021 09:08:18 +0000 (10:08 +0100)
This counter could be hugely incremented by the peer task responsible of managing
peer synchronizations and reconnections, for instance when a peer is not reachable
there is a period where the appctx is not created. If we receive  stick-table
updates before the peer session (appctx) is instantiated, we reach the code
responsible of incrementing the "new_conn" counter.
With this patch we increment this counter only when we really instantiate a new
peer session thanks to peer_session_create().

May be backported as far as 2.0.

src/peers.c

index 754d73a8a84d43e359d7fe6623db19eef417047a..f4553bc8de513c47e713abec9c6644385ef75701 100644 (file)
@@ -2807,6 +2807,7 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer
        struct session *sess;
        struct stream *s;
 
+       peer->new_conn++;
        peer->reconnect = tick_add(now_ms, MS_TO_TICKS(PEER_RECONNECT_TIMEOUT));
        peer->heartbeat = TICK_ETERNITY;
        peer->statuscode = PEER_SESS_SC_CONNECTCODE;
@@ -2931,7 +2932,6 @@ static struct task *process_peer_sync(struct task * task, void *context, unsigne
 
                                                /* reschedule task for reconnect */
                                                task->expire = tick_first(task->expire, ps->reconnect);
-                                               ps->new_conn++;
                                        }
                                        /* else do nothing */
                                } /* !ps->appctx */