mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
MINOR: h2: Use BUG_ON() to enforce rules in subscribe/unsubscribe.
It is not legal to subscribe if we're already subscribed, or to unsubscribe if we did not subscribe, so instead of trying to handle those cases, just assert that it's ok using the new BUG_ON() macro.
This commit is contained in:
parent
469fa2c9d9
commit
f8338151a3
55
src/mux_h2.c
55
src/mux_h2.c
@ -5199,24 +5199,22 @@ static int h2_subscribe(struct conn_stream *cs, int event_type, void *param)
|
|||||||
|
|
||||||
if (event_type & SUB_RETRY_RECV) {
|
if (event_type & SUB_RETRY_RECV) {
|
||||||
sw = param;
|
sw = param;
|
||||||
if (!(sw->events & SUB_RETRY_RECV)) {
|
BUG_ON(h2s->recv_wait != NULL || (sw->events & SUB_RETRY_RECV));
|
||||||
sw->events |= SUB_RETRY_RECV;
|
sw->events |= SUB_RETRY_RECV;
|
||||||
h2s->recv_wait = sw;
|
h2s->recv_wait = sw;
|
||||||
}
|
|
||||||
event_type &= ~SUB_RETRY_RECV;
|
event_type &= ~SUB_RETRY_RECV;
|
||||||
}
|
}
|
||||||
if (event_type & SUB_RETRY_SEND) {
|
if (event_type & SUB_RETRY_SEND) {
|
||||||
sw = param;
|
sw = param;
|
||||||
if (!(sw->events & SUB_RETRY_SEND)) {
|
BUG_ON(h2s->send_wait != NULL || (sw->events & SUB_RETRY_SEND));
|
||||||
sw->events |= SUB_RETRY_SEND;
|
sw->events |= SUB_RETRY_SEND;
|
||||||
h2s->send_wait = sw;
|
h2s->send_wait = sw;
|
||||||
if (!(h2s->flags & H2_SF_BLK_SFCTL) &&
|
if (!(h2s->flags & H2_SF_BLK_SFCTL) &&
|
||||||
!LIST_ADDED(&h2s->list)) {
|
!LIST_ADDED(&h2s->list)) {
|
||||||
if (h2s->flags & H2_SF_BLK_MFCTL)
|
if (h2s->flags & H2_SF_BLK_MFCTL)
|
||||||
LIST_ADDQ(&h2c->fctl_list, &h2s->list);
|
LIST_ADDQ(&h2c->fctl_list, &h2s->list);
|
||||||
else
|
else
|
||||||
LIST_ADDQ(&h2c->send_list, &h2s->list);
|
LIST_ADDQ(&h2c->send_list, &h2s->list);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
event_type &= ~SUB_RETRY_SEND;
|
event_type &= ~SUB_RETRY_SEND;
|
||||||
}
|
}
|
||||||
@ -5237,26 +5235,23 @@ static int h2_unsubscribe(struct conn_stream *cs, int event_type, void *param)
|
|||||||
|
|
||||||
if (event_type & SUB_RETRY_RECV) {
|
if (event_type & SUB_RETRY_RECV) {
|
||||||
sw = param;
|
sw = param;
|
||||||
if (h2s->recv_wait == sw) {
|
BUG_ON(h2s->recv_wait != sw);
|
||||||
sw->events &= ~SUB_RETRY_RECV;
|
sw->events &= ~SUB_RETRY_RECV;
|
||||||
h2s->recv_wait = NULL;
|
h2s->recv_wait = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (event_type & SUB_RETRY_SEND) {
|
if (event_type & SUB_RETRY_SEND) {
|
||||||
sw = param;
|
sw = param;
|
||||||
if (h2s->send_wait == sw) {
|
BUG_ON(h2s->send_wait != sw);
|
||||||
LIST_DEL(&h2s->list);
|
LIST_DEL(&h2s->list);
|
||||||
LIST_INIT(&h2s->list);
|
LIST_INIT(&h2s->list);
|
||||||
sw->events &= ~SUB_RETRY_SEND;
|
sw->events &= ~SUB_RETRY_SEND;
|
||||||
/* We were about to send, make sure it does not happen */
|
/* We were about to send, make sure it does not happen */
|
||||||
if (LIST_ADDED(&h2s->sending_list) &&
|
if (LIST_ADDED(&h2s->sending_list) &&
|
||||||
h2s->send_wait != &h2s->wait_event) {
|
h2s->send_wait != &h2s->wait_event) {
|
||||||
task_remove_from_tasklet_list((struct task *)h2s->send_wait->task);
|
task_remove_from_tasklet_list((struct task *)h2s->send_wait->task);
|
||||||
LIST_DEL_INIT(&h2s->sending_list);
|
LIST_DEL_INIT(&h2s->sending_list);
|
||||||
}
|
|
||||||
h2s->send_wait = NULL;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
h2s->send_wait = NULL;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user