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
* 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;
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--;
srv_conn->flags &= ~CO_FL_SESS_IDLE;
sess->idle_conns--;
}
}
}