CLEANUP: conn_stream: apply endp_flags.cocci tree-wide
This changes all main uses of endp->flags to the se_fl_*() equivalent
by applying coccinelle script endp_flags.cocci. The se_fl_*() functions
themselves were manually excluded from the change, of course.
Note: 144 locations were touched, manually reviewed and found to be OK.
The script was applied with all includes:
spatch --in-place --recursive-includes -I include --sp-file $script $files
diff --git a/src/mux_h2.c b/src/mux_h2.c
index cd57d98..25969c9 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -1485,7 +1485,7 @@
if (!h2s->id)
h2s->h2c->nb_reserved--;
if (h2s->endp->cs) {
- if (!(h2s->endp->flags & CS_EP_EOS) && !b_data(&h2s->rxbuf))
+ if (!se_fl_test(h2s->endp, CS_EP_EOS) && !b_data(&h2s->rxbuf))
h2s_notify_recv(h2s);
}
HA_ATOMIC_DEC(&h2s->h2c->px_counters->open_streams);
@@ -1524,7 +1524,7 @@
/* ditto, calling tasklet_free() here should be ok */
tasklet_free(h2s->shut_tl);
- BUG_ON(h2s->endp && !(h2s->endp->flags & CS_EP_ORPHAN));
+ BUG_ON(h2s->endp && !se_fl_test(h2s->endp, CS_EP_ORPHAN));
cs_endpoint_free(h2s->endp);
pool_free(pool_head_h2s, h2s);
@@ -1614,13 +1614,13 @@
goto out_close;
h2s->endp->target = h2s;
h2s->endp->conn = h2c->conn;
- h2s->endp->flags |= (CS_EP_T_MUX|CS_EP_ORPHAN|CS_EP_NOT_FIRST);
+ se_fl_set(h2s->endp, CS_EP_T_MUX | CS_EP_ORPHAN | CS_EP_NOT_FIRST);
/* FIXME wrong analogy between ext-connect and websocket, this need to
* be refine.
*/
if (flags & H2_SF_EXT_CONNECT_RCVD)
- h2s->endp->flags |= CS_EP_WEBSOCKET;
+ se_fl_set(h2s->endp, CS_EP_WEBSOCKET);
/* The stream will record the request's accept date (which is either the
* end of the connection's or the date immediately after the previous
@@ -2212,9 +2212,9 @@
if ((h2s->h2c->st0 >= H2_CS_ERROR || h2s->h2c->conn->flags & CO_FL_ERROR) ||
(h2s->h2c->last_sid > 0 && (!h2s->id || h2s->id > h2s->h2c->last_sid))) {
- h2s->endp->flags |= CS_EP_ERR_PENDING;
- if (h2s->endp->flags & CS_EP_EOS)
- h2s->endp->flags |= CS_EP_ERROR;
+ se_fl_set(h2s->endp, CS_EP_ERR_PENDING);
+ if (se_fl_test(h2s->endp, CS_EP_EOS))
+ se_fl_set(h2s->endp, CS_EP_ERROR);
if (h2s->st < H2_SS_ERROR)
h2s->st = H2_SS_ERROR;
@@ -2978,7 +2978,7 @@
if (h2c->dff & H2_F_HEADERS_END_STREAM)
h2s->flags |= H2_SF_ES_RCVD;
- if (h2s->endp->flags & CS_EP_ERROR && h2s->st < H2_SS_ERROR)
+ if (se_fl_test(h2s->endp, CS_EP_ERROR) && h2s->st < H2_SS_ERROR)
h2s->st = H2_SS_ERROR;
else if (h2s->flags & H2_SF_ES_RCVD) {
if (h2s->st == H2_SS_OPEN)
@@ -3479,10 +3479,10 @@
h2c_read0_pending(h2c) ||
h2s->st == H2_SS_CLOSED ||
(h2s->flags & H2_SF_ES_RCVD) ||
- (h2s->endp->flags & (CS_EP_ERROR|CS_EP_ERR_PENDING|CS_EP_EOS)))) {
+ se_fl_test(h2s->endp, CS_EP_ERROR | CS_EP_ERR_PENDING | CS_EP_EOS))) {
/* we may have to signal the upper layers */
TRACE_DEVEL("notifying stream before switching SID", H2_EV_RX_FRAME|H2_EV_STRM_WAKE, h2c->conn, h2s);
- h2s->endp->flags |= CS_EP_RCV_MORE;
+ se_fl_set(h2s->endp, CS_EP_RCV_MORE);
h2s_notify_recv(h2s);
}
h2s = tmp_h2s;
@@ -3650,10 +3650,10 @@
h2c_read0_pending(h2c) ||
h2s->st == H2_SS_CLOSED ||
(h2s->flags & H2_SF_ES_RCVD) ||
- (h2s->endp->flags & (CS_EP_ERROR|CS_EP_ERR_PENDING|CS_EP_EOS)))) {
+ se_fl_test(h2s->endp, CS_EP_ERROR | CS_EP_ERR_PENDING | CS_EP_EOS))) {
/* we may have to signal the upper layers */
TRACE_DEVEL("notifying stream before switching SID", H2_EV_RX_FRAME|H2_EV_H2S_WAKE, h2c->conn, h2s);
- h2s->endp->flags |= CS_EP_RCV_MORE;
+ se_fl_set(h2s->endp, CS_EP_RCV_MORE);
h2s_notify_recv(h2s);
}
@@ -4102,7 +4102,7 @@
while (node) {
h2s = container_of(node, struct h2s, by_id);
- if (h2s->endp->flags & CS_EP_WAIT_FOR_HS)
+ if (se_fl_test(h2s->endp, CS_EP_WAIT_FOR_HS))
h2s_notify_recv(h2s);
node = eb32_next(node);
}
@@ -4520,7 +4520,7 @@
* normally used to limit abuse. In this case we schedule a goaway to
* close the connection.
*/
- if ((h2s->endp->flags & CS_EP_KILL_CONN) &&
+ if (se_fl_test(h2s->endp, CS_EP_KILL_CONN) &&
!(h2c->flags & (H2_CF_GOAWAY_SENT|H2_CF_GOAWAY_FAILED))) {
TRACE_STATE("stream wants to kill the connection", H2_EV_STRM_SHUT, h2c->conn, h2s);
h2c_error(h2c, H2_ERR_ENHANCE_YOUR_CALM);
@@ -4598,7 +4598,7 @@
* normally used to limit abuse. In this case we schedule a goaway to
* close the connection.
*/
- if ((h2s->endp->flags & CS_EP_KILL_CONN) &&
+ if (se_fl_test(h2s->endp, CS_EP_KILL_CONN) &&
!(h2c->flags & (H2_CF_GOAWAY_SENT|H2_CF_GOAWAY_FAILED))) {
TRACE_STATE("stream wants to kill the connection", H2_EV_STRM_SHUT, h2c->conn, h2s);
h2c_error(h2c, H2_ERR_ENHANCE_YOUR_CALM);
@@ -5338,7 +5338,7 @@
break;
}
- if (!h2s->endp->cs || h2s->endp->flags & CS_EP_SHW) {
+ if (!h2s->endp->cs || se_fl_test(h2s->endp, CS_EP_SHW)) {
/* Response already closed: add END_STREAM */
es_now = 1;
}
@@ -5758,7 +5758,7 @@
break;
}
- if (!h2s->endp->cs || h2s->endp->flags & CS_EP_SHW) {
+ if (!h2s->endp->cs || se_fl_test(h2s->endp, CS_EP_SHW)) {
/* Request already closed: add END_STREAM */
es_now = 1;
}
@@ -6482,7 +6482,7 @@
if (h2s_htx->flags & HTX_FL_PARSING_ERROR) {
buf_htx->flags |= HTX_FL_PARSING_ERROR;
if (htx_is_empty(buf_htx))
- h2s->endp->flags |= CS_EP_EOI;
+ se_fl_set(h2s->endp, CS_EP_EOI);
}
else if (htx_is_empty(h2s_htx))
buf_htx->flags |= (h2s_htx->flags & HTX_FL_EOM);
@@ -6494,19 +6494,19 @@
end:
if (b_data(&h2s->rxbuf))
- h2s->endp->flags |= (CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
+ se_fl_set(h2s->endp, CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
else {
- h2s->endp->flags &= ~(CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
+ se_fl_clr(h2s->endp, CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
if (h2s->flags & H2_SF_ES_RCVD) {
- h2s->endp->flags |= CS_EP_EOI;
+ se_fl_set(h2s->endp, CS_EP_EOI);
/* Add EOS flag for tunnel */
if (h2s->flags & H2_SF_BODY_TUNNEL)
- h2s->endp->flags |= CS_EP_EOS;
+ se_fl_set(h2s->endp, CS_EP_EOS);
}
if (h2c_read0_pending(h2c) || h2s->st == H2_SS_CLOSED)
- h2s->endp->flags |= CS_EP_EOS;
- if (h2s->endp->flags & CS_EP_ERR_PENDING)
- h2s->endp->flags |= CS_EP_ERROR;
+ se_fl_set(h2s->endp, CS_EP_EOS);
+ if (se_fl_test(h2s->endp, CS_EP_ERR_PENDING))
+ se_fl_set(h2s->endp, CS_EP_ERROR);
if (b_size(&h2s->rxbuf)) {
b_free(&h2s->rxbuf);
offer_buffers(NULL, 1);
@@ -6558,7 +6558,7 @@
}
if (h2s->h2c->st0 >= H2_CS_ERROR) {
- h2s->endp->flags |= CS_EP_ERROR;
+ se_fl_set(h2s->endp, CS_EP_ERROR);
TRACE_DEVEL("connection is in error, leaving in error", H2_EV_H2S_SEND|H2_EV_H2S_BLK|H2_EV_H2S_ERR|H2_EV_STRM_ERR, h2s->h2c->conn, h2s);
return 0;
}
@@ -6572,7 +6572,7 @@
int32_t id = h2c_get_next_sid(h2s->h2c);
if (id < 0) {
- h2s->endp->flags |= CS_EP_ERROR;
+ se_fl_set(h2s->endp, CS_EP_ERROR);
TRACE_DEVEL("couldn't get a stream ID, leaving in error", H2_EV_H2S_SEND|H2_EV_H2S_BLK|H2_EV_H2S_ERR|H2_EV_STRM_ERR, h2s->h2c->conn, h2s);
return 0;
}
@@ -6684,10 +6684,10 @@
!b_data(&h2s->h2c->dbuf) &&
(h2s->flags & (H2_SF_BLK_SFCTL | H2_SF_BLK_MFCTL))) {
TRACE_DEVEL("fctl with shutr, reporting error to app-layer", H2_EV_H2S_SEND|H2_EV_STRM_SEND|H2_EV_STRM_ERR, h2s->h2c->conn, h2s);
- if (h2s->endp->flags & CS_EP_EOS)
- h2s->endp->flags |= CS_EP_ERROR;
+ if (se_fl_test(h2s->endp, CS_EP_EOS))
+ se_fl_set(h2s->endp, CS_EP_ERROR);
else
- h2s->endp->flags |= CS_EP_ERR_PENDING;
+ se_fl_set(h2s->endp, CS_EP_ERR_PENDING);
}
if (total > 0 && !(h2s->flags & H2_SF_BLK_SFCTL) &&
@@ -6763,7 +6763,7 @@
chunk_appendf(msg, "endp=%p", h2s->endp);
if (h2s->endp)
chunk_appendf(msg, "(.flg=0x%08x)",
- h2s->endp->flags);
+ se_fl_get(h2s->endp));
chunk_appendf(&trash, " .subs=%p", h2s->subs);
if (h2s->subs) {