MINOR: listener: maintain a per-thread count of the number of connections on a listener

Having this information will help us improve thread-level distribution
of incoming traffic.
This commit is contained in:
Willy Tarreau 2019-02-03 10:36:29 +01:00
parent 3f0d02bbc2
commit 9e85318417
2 changed files with 5 additions and 0 deletions

View File

@ -214,6 +214,9 @@ struct listener {
const struct netns_entry *netns; /* network namespace of the listener*/
/* cache line boundary */
unsigned int thr_conn[MAX_THREADS]; /* number of connections per thread */
/* cache line boundary */
struct list by_fe; /* chaining in frontend's list of listeners */
struct list by_bind; /* chaining in bind_conf's list of listeners */

View File

@ -653,6 +653,7 @@ void listener_accept(int fd)
*/
next_conn = 0;
HA_ATOMIC_ADD(&l->thr_conn[tid], 1);
ret = l->accept(l, cfd, &addr);
if (unlikely(ret <= 0)) {
/* The connection was closed by stream_accept(). Either
@ -723,6 +724,7 @@ void listener_release(struct listener *l)
if (!(l->options & LI_O_UNLIMITED))
HA_ATOMIC_SUB(&actconn, 1);
HA_ATOMIC_SUB(&l->nbconn, 1);
HA_ATOMIC_SUB(&l->thr_conn[tid], 1);
if (l->state == LI_FULL)
resume_listener(l);