diff --git a/include/haproxy/queue-t.h b/include/haproxy/queue-t.h index cbc9d7183..cb317db31 100644 --- a/include/haproxy/queue-t.h +++ b/include/haproxy/queue-t.h @@ -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 */ diff --git a/include/haproxy/queue.h b/include/haproxy/queue.h index 3e7950787..847896545 100644 --- a/include/haproxy/queue.h +++ b/include/haproxy/queue.h @@ -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 for proxy and server . 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); } diff --git a/src/proxy.c b/src/proxy.c index 3c679509c..764207d1d 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -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); diff --git a/src/server.c b/src/server.c index 95a479d33..d63c3f1e3 100644 --- a/src/server.c +++ b/src/server.c @@ -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);