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.
This commit is contained in:
Christopher Faulet 2019-04-19 15:39:22 +02:00
parent f48552f2c1
commit 46451d6e04

View File

@ -1374,18 +1374,21 @@ int connect_server(struct stream *s)
/* If we're really reusing the connection, remove it from the orphan /* If we're really reusing the connection, remove it from the orphan
* list and add it back to the idle list. * list and add it back to the idle list.
*/ */
if (reuse && reuse_orphan) { if (reuse) {
srv_conn->idle_time = 0; if (reuse_orphan) {
_HA_ATOMIC_SUB(&srv->curr_idle_conns, 1); srv_conn->idle_time = 0;
__ha_barrier_atomic_store(); _HA_ATOMIC_SUB(&srv->curr_idle_conns, 1);
srv->curr_idle_thr[tid]--; __ha_barrier_atomic_store();
LIST_ADDQ(&srv->idle_conns[tid], &srv_conn->list); srv->curr_idle_thr[tid]--;
} else if (reuse) { LIST_ADDQ(&srv->idle_conns[tid], &srv_conn->list);
if (srv_conn->flags & CO_FL_SESS_IDLE) { }
struct session *sess = srv_conn->owner; else {
if (srv_conn->flags & CO_FL_SESS_IDLE) {
struct session *sess = srv_conn->owner;
srv_conn->flags &= ~CO_FL_SESS_IDLE; srv_conn->flags &= ~CO_FL_SESS_IDLE;
sess->idle_conns--; sess->idle_conns--;
}
} }
} }