From a9d7b76f6a5824fd2d36ce11fa0a1a1c504f1104 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 10 Jul 2020 08:28:20 +0200 Subject: [PATCH] MINOR: connection: use MT_LIST_ADDQ() to add connections to idle lists 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 | 4 ++-- src/backend.c | 2 +- src/mux_fcgi.c | 4 ++-- src/mux_h1.c | 4 ++-- src/mux_h2.c | 4 ++-- src/ssl_sock.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/haproxy/server.h b/include/haproxy/server.h index 9a400fdb76..3ad60d0cde 100644 --- a/include/haproxy/server.h +++ b/include/haproxy/server.h @@ -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); diff --git a/src/backend.c b/src/backend.c index 4a162a4308..324d7565a4 100644 --- a/src/backend.c +++ b/src/backend.c @@ -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); diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 7165e39155..a0509e66a6 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -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; } diff --git a/src/mux_h1.c b/src/mux_h1.c index ae3bca38c8..80a7b7db51 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -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; } diff --git a/src/mux_h2.c b/src/mux_h2.c index d02a04d8ec..6ec8d27cab 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -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: diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 54da3a0acd..69f6835c49 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -5676,9 +5676,9 @@ static struct task *ssl_sock_io_cb(struct task *t, void *context, unsigned short 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; }