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 9a400fd..3ad60d0 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 4a162a4..324d756 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 7165e39..a0509e6 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 ae3bca3..80a7b7d 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 d02a04d..6ec8d27 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 54da3a0..69f6835 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;
 }