mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 14:21:00 +01:00
MINOR: queue: add queue_init() to initialize a queue
This is better and cleaner than open-coding this in the server and proxy code, where it has all chances of becoming wrong once forgotten.
This commit is contained in:
parent
ae0b12ee03
commit
df3b0cbe31
@ -109,6 +109,13 @@ static inline int queue_limit_offset(int offset)
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void queue_init(struct queue *queue)
|
||||||
|
{
|
||||||
|
queue->head = EB_ROOT;
|
||||||
|
queue->length = 0;
|
||||||
|
queue->idx = 0;
|
||||||
|
HA_SPIN_INIT(&queue->lock);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _HAPROXY_QUEUE_H */
|
#endif /* _HAPROXY_QUEUE_H */
|
||||||
|
|
||||||
|
|||||||
@ -1292,8 +1292,7 @@ void init_new_proxy(struct proxy *p)
|
|||||||
{
|
{
|
||||||
memset(p, 0, sizeof(struct proxy));
|
memset(p, 0, sizeof(struct proxy));
|
||||||
p->obj_type = OBJ_TYPE_PROXY;
|
p->obj_type = OBJ_TYPE_PROXY;
|
||||||
p->queue.head = EB_ROOT;
|
queue_init(&p->queue);
|
||||||
HA_SPIN_INIT(&p->queue.lock);
|
|
||||||
LIST_INIT(&p->acl);
|
LIST_INIT(&p->acl);
|
||||||
LIST_INIT(&p->http_req_rules);
|
LIST_INIT(&p->http_req_rules);
|
||||||
LIST_INIT(&p->http_res_rules);
|
LIST_INIT(&p->http_res_rules);
|
||||||
|
|||||||
@ -2160,8 +2160,7 @@ struct server *new_server(struct proxy *proxy)
|
|||||||
|
|
||||||
srv->obj_type = OBJ_TYPE_SERVER;
|
srv->obj_type = OBJ_TYPE_SERVER;
|
||||||
srv->proxy = proxy;
|
srv->proxy = proxy;
|
||||||
srv->queue.head = EB_ROOT;
|
queue_init(&srv->queue);
|
||||||
HA_SPIN_INIT(&srv->queue.lock);
|
|
||||||
LIST_APPEND(&servers_list, &srv->global_list);
|
LIST_APPEND(&servers_list, &srv->global_list);
|
||||||
LIST_INIT(&srv->srv_rec_item);
|
LIST_INIT(&srv->srv_rec_item);
|
||||||
LIST_INIT(&srv->ip_rec_item);
|
LIST_INIT(&srv->ip_rec_item);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user