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.
diff --git a/include/haproxy/server.h b/include/haproxy/server.h
index 9a400fd..3ad60d0 100644
--- a/include/haproxy/server.h
+++ b/include/haproxy/server.h
@@ -273,11 +273,11 @@
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 4a162a4..324d756 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1345,7 +1345,7 @@
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 7165e39..a0509e6 100644
--- a/src/mux_fcgi.c
+++ b/src/mux_fcgi.c
@@ -2956,9 +2956,9 @@
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 ae3bca3..80a7b7d 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -2265,9 +2265,9 @@
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 d02a04d..6ec8d27 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -3565,9 +3565,9 @@
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 54da3a0..69f6835 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -5676,9 +5676,9 @@
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;
}