]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: queue: add a pointer to the server and the proxy in the queue
authorWilly Tarreau <w@1wt.eu>
Wed, 23 Jun 2021 14:11:02 +0000 (16:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 24 Jun 2021 08:52:31 +0000 (10:52 +0200)
A queue is specific to a server or a proxy, so we don't need to place
this distinction inside all pendconns, it can be in the queue itself.
This commit adds the relevant fields "px" and "sv" into the struct
queue, and initializes them accordingly.

include/haproxy/queue-t.h
include/haproxy/queue.h
src/proxy.c
src/server.c

index cbc9d7183eb1b82881e781775602431336f93a98..cb317db3133a5753fa99ab2175635b9241691e5e 100644 (file)
@@ -41,6 +41,8 @@ struct pendconn {
 
 struct queue {
        struct eb_root head;                    /* queued pendconnds */
+       struct proxy  *px;                      /* the proxy we're waiting for, never NULL in queue */
+       struct server *sv;                      /* the server we are waiting for, may be NULL if don't care */
        __decl_thread(HA_SPINLOCK_T lock);      /* for manipulations in the tree */
        unsigned int idx;                       /* current queuing index */
        unsigned int length;                    /* number of entries */
index 3e79507876f78b0f6ba9f58e344511fe29f0c3d4..8478965458a711a0d12785fe61675e34e6ec4b74 100644 (file)
@@ -109,11 +109,18 @@ static inline int queue_limit_offset(int offset)
        return offset;
 }
 
-static inline void queue_init(struct queue *queue)
+/* initialize the queue <queue> for proxy <px> and server <sv>. A server's
+ * always has both a valid proxy and a valid server. A proxy's queue only
+ * has a valid proxy and NULL for the server queue. This is how they're
+ * distinguished during operations.
+ */
+static inline void queue_init(struct queue *queue, struct proxy *px, struct server *sv)
 {
        queue->head = EB_ROOT;
        queue->length = 0;
        queue->idx = 0;
+       queue->px = px;
+       queue->sv = sv;
        HA_SPIN_INIT(&queue->lock);
 }
 
index 3c679509c034c4c0b823b4023a15fd14f6368c3e..764207d1d95fcc36710be0b7fd114abf9dd9000a 100644 (file)
@@ -1292,7 +1292,7 @@ void init_new_proxy(struct proxy *p)
 {
        memset(p, 0, sizeof(struct proxy));
        p->obj_type = OBJ_TYPE_PROXY;
-       queue_init(&p->queue);
+       queue_init(&p->queue, p, NULL);
        LIST_INIT(&p->acl);
        LIST_INIT(&p->http_req_rules);
        LIST_INIT(&p->http_res_rules);
index 95a479d339cab01b56279591dad04914fcb9eb1a..d63c3f1e3805e60d0e86cee108695a13610bf403 100644 (file)
@@ -2160,7 +2160,7 @@ struct server *new_server(struct proxy *proxy)
 
        srv->obj_type = OBJ_TYPE_SERVER;
        srv->proxy = proxy;
-       queue_init(&srv->queue);
+       queue_init(&srv->queue, proxy, srv);
        LIST_APPEND(&servers_list, &srv->global_list);
        LIST_INIT(&srv->srv_rec_item);
        LIST_INIT(&srv->ip_rec_item);