]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: use MT_LIST_ADDQ() to add connections to idle lists
authorWilly Tarreau <w@1wt.eu>
Fri, 10 Jul 2020 06:28:20 +0000 (08:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Jul 2020 06:52:13 +0000 (08:52 +0200)
When a connection is added to an idle list, it's already detached and
cannot be seen by two threads at once, so there's no point using
TRY_ADDQ, there will never be any conflict. Let's just use the cheaper
ADDQ.

include/haproxy/server.h
src/backend.c
src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c
src/ssl_sock.c

index 9a400fdb76dc6e7fc372c9f1951569fac7cca3a8..3ad60d0cde12fcebe321fe5ac64da041cd60ee3c 100644 (file)
@@ -273,11 +273,11 @@ static inline int srv_add_to_idle_list(struct server *srv, struct connection *co
                conn->idle_time = now_ms;
                if (is_safe) {
                        conn->flags = (conn->flags & ~CO_FL_LIST_MASK) | CO_FL_SAFE_LIST;
-                       MT_LIST_TRY_ADDQ(&srv->safe_conns[tid], (struct mt_list *)&conn->list);
+                       MT_LIST_ADDQ(&srv->safe_conns[tid], (struct mt_list *)&conn->list);
                        _HA_ATOMIC_ADD(&srv->curr_safe_nb, 1);
                } else {
                        conn->flags = (conn->flags & ~CO_FL_LIST_MASK) | CO_FL_IDLE_LIST;
-                       MT_LIST_TRY_ADDQ(&srv->idle_conns[tid], (struct mt_list *)&conn->list);
+                       MT_LIST_ADDQ(&srv->idle_conns[tid], (struct mt_list *)&conn->list);
                        _HA_ATOMIC_ADD(&srv->curr_idle_nb, 1);
                }
                _HA_ATOMIC_ADD(&srv->curr_idle_thr[tid], 1);
index 4a162a43080218028a67ea71ec0c563583581e3c..324d7565a4f2836f7bc0012c561e04855b59102b 100644 (file)
@@ -1345,7 +1345,7 @@ int connect_server(struct stream *s)
                                if (tokill_conn) {
                                        /* We got one, put it into the concerned thread's to kill list, and wake it's kill task */
 
-                                       MT_LIST_TRY_ADDQ(&idle_conns[i].toremove_conns,
+                                       MT_LIST_ADDQ(&idle_conns[i].toremove_conns,
                                            (struct mt_list *)&tokill_conn->list);
                                        task_wakeup(idle_conns[i].cleanup_task, TASK_WOKEN_OTHER);
                                        HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
index 7165e391557e2711f373f26f8574a322c9b00f25..a0509e66a6a4c1ccfb409b9a7fff28e942b9d014 100644 (file)
@@ -2956,9 +2956,9 @@ static struct task *fcgi_io_cb(struct task *t, void *ctx, unsigned short status)
                struct server *srv = objt_server(conn->target);
 
                if (conn_in_list == CO_FL_SAFE_LIST)
-                       MT_LIST_TRY_ADDQ(&srv->safe_conns[tid], &conn->list);
+                       MT_LIST_ADDQ(&srv->safe_conns[tid], &conn->list);
                else
-                       MT_LIST_TRY_ADDQ(&srv->idle_conns[tid], &conn->list);
+                       MT_LIST_ADDQ(&srv->idle_conns[tid], &conn->list);
        }
        return NULL;
 }
index ae3bca38c839c64ec6bf764dbb7a40d1ba833ff4..80a7b7db51f78021e42c4554da41032283fe4eb7 100644 (file)
@@ -2265,9 +2265,9 @@ static struct task *h1_io_cb(struct task *t, void *ctx, unsigned short status)
                struct server *srv = objt_server(conn->target);
 
                if (conn_in_list == CO_FL_SAFE_LIST)
-                       MT_LIST_TRY_ADDQ(&srv->safe_conns[tid], &conn->list);
+                       MT_LIST_ADDQ(&srv->safe_conns[tid], &conn->list);
                else
-                       MT_LIST_TRY_ADDQ(&srv->idle_conns[tid], &conn->list);
+                       MT_LIST_ADDQ(&srv->idle_conns[tid], &conn->list);
        }
        return NULL;
 }
index d02a04d8ecd1450f0504ec2ed77c622bbe8a7203..6ec8d27cabe9a0b7d926f28e63d2af91c2401c37 100644 (file)
@@ -3565,9 +3565,9 @@ static struct task *h2_io_cb(struct task *t, void *ctx, unsigned short status)
                struct server *srv = objt_server(conn->target);
 
                if (conn_in_list == CO_FL_SAFE_LIST)
-                       MT_LIST_TRY_ADDQ(&srv->safe_conns[tid], &conn->list);
+                       MT_LIST_ADDQ(&srv->safe_conns[tid], &conn->list);
                else
-                       MT_LIST_TRY_ADDQ(&srv->idle_conns[tid], &conn->list);
+                       MT_LIST_ADDQ(&srv->idle_conns[tid], &conn->list);
        }
 
 leave:
index 54da3a0acd4220e610fe8f9d29380ca9daddc561..69f6835c4973eeb97cc9a3b181bd77d0f6604459 100644 (file)
@@ -5676,9 +5676,9 @@ leave:
                struct server *srv = objt_server(conn->target);
 
                if (conn_in_list == CO_FL_SAFE_LIST)
-                       MT_LIST_TRY_ADDQ(&srv->safe_conns[tid], &conn->list);
+                       MT_LIST_ADDQ(&srv->safe_conns[tid], &conn->list);
                else
-                       MT_LIST_TRY_ADDQ(&srv->idle_conns[tid], &conn->list);
+                       MT_LIST_ADDQ(&srv->idle_conns[tid], &conn->list);
        }
        return NULL;
 }