]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: gcc: Fix a silly gcc warning in connect_server()
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 19 Apr 2019 13:39:22 +0000 (15:39 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 19 Apr 2019 13:53:23 +0000 (15:53 +0200)
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.

src/backend.c

index 40ce949872b789a22562e65ed9369896a41c4ed2..d7695bf2ce32cc41518a24e054561a357a983c03 100644 (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;
-
-                       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--;
+                       }
                }
        }