From: Christopher Faulet Date: Fri, 19 Apr 2019 13:39:22 +0000 (+0200) Subject: MINOR: gcc: Fix a silly gcc warning in connect_server() X-Git-Tag: v2.0-dev3~206 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=46451d6e04c7fd384ae3846662cfb025c0ce6f43;p=thirdparty%2Fhaproxy.git MINOR: gcc: Fix a silly gcc warning in connect_server() Don't know why it happens now, but gcc seems to think srv_conn may be NULL when a reused connection is removed from the orphan list. It happens when HAProxy is compiled with -O2 with my gcc (8.3.1) on fedora 29... Changing a little how reuse parameter is tested removes the warnings. So... This patch may be backported to 1.9. --- diff --git a/src/backend.c b/src/backend.c index 40ce949872..d7695bf2ce 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1374,18 +1374,21 @@ int connect_server(struct stream *s) /* If we're really reusing the connection, remove it from the orphan * list and add it back to the idle list. */ - if (reuse && reuse_orphan) { - srv_conn->idle_time = 0; - _HA_ATOMIC_SUB(&srv->curr_idle_conns, 1); - __ha_barrier_atomic_store(); - srv->curr_idle_thr[tid]--; - LIST_ADDQ(&srv->idle_conns[tid], &srv_conn->list); - } else if (reuse) { - if (srv_conn->flags & CO_FL_SESS_IDLE) { - struct session *sess = srv_conn->owner; - - srv_conn->flags &= ~CO_FL_SESS_IDLE; - sess->idle_conns--; + if (reuse) { + if (reuse_orphan) { + srv_conn->idle_time = 0; + _HA_ATOMIC_SUB(&srv->curr_idle_conns, 1); + __ha_barrier_atomic_store(); + srv->curr_idle_thr[tid]--; + LIST_ADDQ(&srv->idle_conns[tid], &srv_conn->list); + } + else { + if (srv_conn->flags & CO_FL_SESS_IDLE) { + struct session *sess = srv_conn->owner; + + srv_conn->flags &= ~CO_FL_SESS_IDLE; + sess->idle_conns--; + } } }