mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-01 09:42:02 +00:00
MINOR: h1: 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
f8338151a3
commit
00b8f7c60b
28
src/mux_h1.c
28
src/mux_h1.c
@ -2178,17 +2178,15 @@ static int h1_unsubscribe(struct conn_stream *cs, int event_type, void *param)
|
||||
|
||||
if (event_type & SUB_RETRY_RECV) {
|
||||
sw = param;
|
||||
if (h1s->recv_wait == sw) {
|
||||
sw->events &= ~SUB_RETRY_RECV;
|
||||
h1s->recv_wait = NULL;
|
||||
}
|
||||
BUG_ON(h1s->recv_wait != sw);
|
||||
sw->events &= ~SUB_RETRY_RECV;
|
||||
h1s->recv_wait = NULL;
|
||||
}
|
||||
if (event_type & SUB_RETRY_SEND) {
|
||||
sw = param;
|
||||
if (h1s->send_wait == sw) {
|
||||
sw->events &= ~SUB_RETRY_SEND;
|
||||
h1s->send_wait = NULL;
|
||||
}
|
||||
BUG_ON(h1s->send_wait != sw);
|
||||
sw->events &= ~SUB_RETRY_SEND;
|
||||
h1s->send_wait = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -2205,17 +2203,15 @@ static int h1_subscribe(struct conn_stream *cs, int event_type, void *param)
|
||||
switch (event_type) {
|
||||
case SUB_RETRY_RECV:
|
||||
sw = param;
|
||||
if (!(sw->events & SUB_RETRY_RECV)) {
|
||||
sw->events |= SUB_RETRY_RECV;
|
||||
h1s->recv_wait = sw;
|
||||
}
|
||||
BUG_ON(h1s->recv_wait != NULL || (sw->events & SUB_RETRY_RECV));
|
||||
sw->events |= SUB_RETRY_RECV;
|
||||
h1s->recv_wait = sw;
|
||||
return 0;
|
||||
case SUB_RETRY_SEND:
|
||||
sw = param;
|
||||
if (!(sw->events & SUB_RETRY_SEND)) {
|
||||
sw->events |= SUB_RETRY_SEND;
|
||||
h1s->send_wait = sw;
|
||||
}
|
||||
BUG_ON(h1s->send_wait != NULL || (sw->events & SUB_RETRY_SEND));
|
||||
sw->events |= SUB_RETRY_SEND;
|
||||
h1s->send_wait = sw;
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user