[MINOR] Add active connection list to server
The motivation for this is to allow iteration of all the connections
of a server without the expense of iterating over the global list
of connections.
The first use of this will be to implement an option to close connections
associated with a server when is is marked as being down or in maintenance
mode.
diff --git a/include/proto/session.h b/include/proto/session.h
index c9195f6..810fe44 100644
--- a/include/proto/session.h
+++ b/include/proto/session.h
@@ -225,6 +225,21 @@
}
}
+static void inline session_add_srv_conn(struct session *sess, struct server *srv)
+{
+ sess->srv_conn = srv;
+ LIST_ADD(&srv->actconns, &sess->by_srv);
+}
+
+static void inline session_del_srv_conn(struct session *sess)
+{
+ if (!sess->srv_conn)
+ return;
+
+ sess->srv_conn = NULL;
+ LIST_DEL(&sess->by_srv);
+}
+
#endif /* _PROTO_SESSION_H */
/*
diff --git a/include/types/server.h b/include/types/server.h
index fb31215..cf0a0df 100644
--- a/include/types/server.h
+++ b/include/types/server.h
@@ -101,6 +101,7 @@
struct srvcounters counters; /* statistics counters */
struct list pendconns; /* pending connections */
+ struct list actconns; /* active connections */
struct task *check; /* the task associated to the health check processing */
struct sockaddr_storage addr; /* the address to connect to */
diff --git a/include/types/session.h b/include/types/session.h
index 2ac2232..7fde0aa 100644
--- a/include/types/session.h
+++ b/include/types/session.h
@@ -157,6 +157,7 @@
*/
struct session {
struct list list; /* position in global sessions list */
+ struct list by_srv; /* position in server session list */
struct list back_refs; /* list of users tracking this session */
struct task *task; /* the task associated with this session */
/* application specific below */