From d2489e00b040a181870338df64683b6f113cdbd2 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Tue, 10 Mar 2020 18:04:37 +0100 Subject: [PATCH] MINOR: connections: Add a flag to know if we're in the safe or idle list. Add flags to connections, CO_FL_SAFE_LIST and CO_FL_IDLE_LIST, to let one know we are in the safe list, or the idle list. --- include/proto/server.h | 2 ++ include/types/connection.h | 4 ++++ src/backend.c | 1 + 3 files changed, 7 insertions(+) diff --git a/include/proto/server.h b/include/proto/server.h index ca794ab9c..7ba9c8346 100644 --- a/include/proto/server.h +++ b/include/proto/server.h @@ -262,6 +262,8 @@ static inline int srv_add_to_idle_list(struct server *srv, struct connection *co return 0; } MT_LIST_DEL(&conn->list); + conn->flags = (conn->flags &~ CO_FL_LIST_MASK) | + (is_safe ? CO_FL_SAFE_LIST : CO_FL_IDLE_LIST); MT_LIST_ADDQ(is_safe ? &srv->safe_conns[tid] : &srv->idle_conns[tid], (struct mt_list *)&conn->list); srv->curr_idle_thr[tid]++; diff --git a/include/types/connection.h b/include/types/connection.h index 32a8590eb..4f02895f0 100644 --- a/include/types/connection.h +++ b/include/types/connection.h @@ -140,6 +140,10 @@ enum { CO_FL_NONE = 0x00000000, /* Just for initialization purposes */ /* Do not change these values without updating conn_*_poll_changes() ! */ + CO_FL_SAFE_LIST = 0x00000001, /* 0 = not in any list, 1 = in safe_list */ + CO_FL_IDLE_LIST = 0x00000002, /* 2 = in idle_list, 3 = invalid */ + CO_FL_LIST_MASK = 0x00000003, /* Is the connection in any server-managed list ? */ + /* unused : 0x00000001 */ /* unused : 0x00000002 */ /* unused : 0x00000004, 0x00000008 */ diff --git a/src/backend.c b/src/backend.c index b60e9000a..c868d93e2 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1173,6 +1173,7 @@ int connect_server(struct stream *s) if (srv_conn) { reuse_orphan = 1; reuse = 1; + srv_conn->flags &= ~CO_FL_LIST_MASK; } }