]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: listener: maintain a per-thread count of the number of connections on a listener
authorWilly Tarreau <w@1wt.eu>
Sun, 3 Feb 2019 09:36:29 +0000 (10:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 27 Feb 2019 13:27:07 +0000 (14:27 +0100)
Having this information will help us improve thread-level distribution
of incoming traffic.

include/types/listener.h
src/listener.c

index 1203d17016c7c7c04549d62ffd3cc48a200d2bef..f9eeafaa9af569c8f7315b3fd8b18a04d02ca28a 100644 (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 */
index b4e0bc20b24cf532d8754eb79f1502671acaaffd..f642eb4d0b6f6b8f86314cced419228f57b8e807 100644 (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);