From: Christopher Faulet Date: Thu, 16 Mar 2023 13:40:03 +0000 (+0100) Subject: MINOR: stconn/channel: Move CF_READ_DONTWAIT into the SC and rename it X-Git-Tag: v2.8-dev7~96 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9a790f63ed5b178b759d004e178b95f242851200;p=thirdparty%2Fhaproxy.git MINOR: stconn/channel: Move CF_READ_DONTWAIT into the SC and rename it The channel flag CF_READ_DONTWAIT is renamed to SC_FL_RCV_ONCE and moved into the stream-connector. --- diff --git a/include/haproxy/channel-t.h b/include/haproxy/channel-t.h index a61e4a52ca..0d54d8e4d8 100644 --- a/include/haproxy/channel-t.h +++ b/include/haproxy/channel-t.h @@ -106,7 +106,7 @@ #define CF_WROTE_DATA 0x00040000 /* some data were sent from this buffer */ /* unused 0x00080000 - 0x00100000 */ #define CF_KERN_SPLICING 0x00200000 /* kernel splicing desired for this channel */ -#define CF_READ_DONTWAIT 0x00400000 /* wake the task up after every read (eg: HTTP request) */ +/* unused 0x00400000 */ #define CF_AUTO_CONNECT 0x00800000 /* consumer may attempt to establish a new connection */ #define CF_DONT_READ 0x01000000 /* disable reading for now */ @@ -140,10 +140,10 @@ static forceinline char *chn_show_flags(char *buf, size_t len, const char *delim _(CF_WRITE_TIMEOUT, _(CF_WAKE_WRITE, _(CF_SHUTW, _(CF_SHUTW_NOW, _(CF_AUTO_CLOSE, _(CF_STREAMER, _(CF_STREAMER_FAST, _(CF_WROTE_DATA, - _(CF_KERN_SPLICING, _(CF_READ_DONTWAIT, + _(CF_KERN_SPLICING, _(CF_AUTO_CONNECT, _(CF_DONT_READ, _(CF_EXPECT_MORE, _(CF_SEND_DONTWAIT, _(CF_NEVER_WAIT, _(CF_WAKE_ONCE, _(CF_FLT_ANALYZE, - _(CF_EOI, _(CF_ISRESP)))))))))))))))))))))))); + _(CF_EOI, _(CF_ISRESP))))))))))))))))))))))); /* epilogue */ _(~0U); return buf; diff --git a/include/haproxy/stconn-t.h b/include/haproxy/stconn-t.h index be6e3a02d3..7dbb6550b9 100644 --- a/include/haproxy/stconn-t.h +++ b/include/haproxy/stconn-t.h @@ -125,6 +125,8 @@ enum sc_flags { SC_FL_WONT_READ = 0x00000080, /* SC doesn't want to read data */ SC_FL_NEED_BUFF = 0x00000100, /* SC waits for an rx buffer allocation to complete */ SC_FL_NEED_ROOM = 0x00000200, /* SC needs more room in the rx buffer to store incoming data */ + + SC_FL_RCV_ONCE = 0x00000400, /* Don't loop to receive data. cleared after a sucessful receive */ }; /* This function is used to report flags in debugging tools. Please reflect @@ -139,7 +141,8 @@ static forceinline char *sc_show_flags(char *buf, size_t len, const char *delim, /* flags */ _(SC_FL_ISBACK, _(SC_FL_NOLINGER, _(SC_FL_NOHALF, _(SC_FL_DONT_WAKE, _(SC_FL_INDEP_STR, _(SC_FL_WONT_READ, - _(SC_FL_NEED_BUFF, _(SC_FL_NEED_ROOM)))))))); + _(SC_FL_NEED_BUFF, _(SC_FL_NEED_ROOM, + _(SC_FL_RCV_ONCE))))))))); /* epilogue */ _(~0U); return buf; diff --git a/src/cli.c b/src/cli.c index 11780090d7..74d13f2e93 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1039,7 +1039,7 @@ static void cli_io_handler(struct appctx *appctx) /* re-adjust req buffer */ co_skip(sc_oc(sc), reql); - req->flags |= CF_READ_DONTWAIT; /* we plan to read small requests */ + sc_opposite(sc)->flags |= SC_FL_RCV_ONCE; /* we plan to read small requests */ } else { /* output functions */ struct cli_print_ctx *ctx; @@ -2636,7 +2636,7 @@ read_again: /* We don't know yet to which server we will connect */ channel_dont_connect(req); - req->flags |= CF_READ_DONTWAIT; + s->scf->flags |= SC_FL_RCV_ONCE; /* need more data */ if (!ci_data(req)) @@ -2738,7 +2738,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit) s->res.analysers &= ~AN_RES_WAIT_CLI; return 0; } - rep->flags |= CF_READ_DONTWAIT; /* try to get back here ASAP */ + s->scb->flags |= SC_FL_RCV_ONCE; /* try to get back here ASAP */ rep->flags |= CF_NEVER_WAIT; /* don't forward the close */ @@ -2869,7 +2869,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit) s->store_count = 0; s->uniq_id = global.req_count++; - s->req.flags |= CF_READ_DONTWAIT; /* one read is usually enough */ + s->scf->flags |= SC_FL_RCV_ONCE; /* one read is usually enough */ s->req.flags |= CF_WAKE_ONCE; /* need to be called again if there is some command left in the request */ diff --git a/src/dns.c b/src/dns.c index 23f423f051..3aca50986c 100644 --- a/src/dns.c +++ b/src/dns.c @@ -832,14 +832,13 @@ static int dns_session_init(struct appctx *appctx) s = appctx_strm(appctx); s->scb->dst = addr; - s->scb->flags |= SC_FL_NOLINGER; + s->scb->flags |= (SC_FL_RCV_ONCE|SC_FL_NOLINGER); s->target = &ds->dss->srv->obj_type; s->flags = SF_ASSIGNED; s->do_log = NULL; s->uniq_id = 0; - s->res.flags |= CF_READ_DONTWAIT; applet_expect_no_data(appctx); ds->appctx = appctx; return 0; diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 327614e44e..0d5d44805e 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -1245,7 +1245,7 @@ spoe_init_appctx(struct appctx *appctx) applet_need_more_data(appctx); s->do_log = NULL; - s->res.flags |= CF_READ_DONTWAIT; + s->scb->flags |= SC_FL_RCV_ONCE; HA_SPIN_LOCK(SPOE_APPLET_LOCK, &agent->rt[tid].lock); LIST_APPEND(&agent->rt[tid].applets, &spoe_appctx->list); diff --git a/src/frontend.c b/src/frontend.c index 7b71357984..33d66df7bd 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -138,7 +138,7 @@ int frontend_accept(struct stream *s) } if (fe->mode == PR_MODE_HTTP) - s->req.flags |= CF_READ_DONTWAIT; /* one read is usually enough */ + s->scf->flags |= SC_FL_RCV_ONCE; /* one read is usually enough */ if (unlikely(fe->nb_req_cap > 0)) { if ((s->req_cap = pool_zalloc(fe->req_cap_pool)) == NULL) diff --git a/src/http_ana.c b/src/http_ana.c index bd2be1b5b2..b8bad1e48d 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -1368,7 +1368,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit) } channel_dont_close(rep); - rep->flags |= CF_READ_DONTWAIT; /* try to get back here ASAP */ + s->scb->flags |= SC_FL_RCV_ONCE; /* try to get back here ASAP */ DBG_TRACE_DEVEL("waiting for more data", STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA, s, txn); return 0; diff --git a/src/http_client.c b/src/http_client.c index a30a941662..c146bd27eb 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -1071,9 +1071,8 @@ static int httpclient_applet_init(struct appctx *appctx) s->scb->dst = addr; } - s->scb->flags |= SC_FL_NOLINGER; + s->scb->flags |= (SC_FL_RCV_ONCE|SC_FL_NOLINGER); s->flags |= SF_ASSIGNED; - s->res.flags |= CF_READ_DONTWAIT; /* applet is waiting for data */ applet_need_more_data(appctx); diff --git a/src/peers.c b/src/peers.c index 89e3bc7822..fab92eec25 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1096,15 +1096,13 @@ static int peer_session_init(struct appctx *appctx) /* initiate an outgoing connection */ s->scb->dst = addr; - s->scb->flags |= SC_FL_NOLINGER; + s->scb->flags |= (SC_FL_RCV_ONCE|SC_FL_NOLINGER); s->flags = SF_ASSIGNED; s->target = peer_session_target(peer, s); s->do_log = NULL; s->uniq_id = 0; - s->res.flags |= CF_READ_DONTWAIT; - _HA_ATOMIC_INC(&active_peers); return 0; @@ -3200,7 +3198,7 @@ send_msgs: } } out: - sc_oc(sc)->flags |= CF_READ_DONTWAIT; + sc_opposite(sc)->flags |= SC_FL_RCV_ONCE; if (curpeer) HA_SPIN_UNLOCK(PEER_LOCK, &curpeer->lock); diff --git a/src/sink.c b/src/sink.c index 042e244a40..9cfe6eafc2 100644 --- a/src/sink.c +++ b/src/sink.c @@ -601,7 +601,7 @@ static int sink_forward_session_init(struct appctx *appctx) s = appctx_strm(appctx); s->scb->dst = addr; - s->scb->flags |= SC_FL_NOLINGER; + s->scb->flags |= (SC_FL_RCV_ONCE|SC_FL_NOLINGER); s->target = &sft->srv->obj_type; s->flags = SF_ASSIGNED; @@ -609,7 +609,6 @@ static int sink_forward_session_init(struct appctx *appctx) s->do_log = NULL; s->uniq_id = 0; - s->res.flags |= CF_READ_DONTWAIT; applet_expect_no_data(appctx); sft->appctx = appctx; diff --git a/src/stconn.c b/src/stconn.c index f8dfb7a38d..cca4a46983 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -1116,7 +1116,7 @@ static void sc_notify(struct stconn *sc) } if (ic->flags & CF_READ_EVENT) - ic->flags &= ~CF_READ_DONTWAIT; + sc->flags &= ~SC_FL_RCV_ONCE; } /* @@ -1382,8 +1382,8 @@ static int sc_conn_recv(struct stconn *sc) if (sc_ep_test(sc, SE_FL_EOI)) break; - if ((ic->flags & CF_READ_DONTWAIT) || --read_poll <= 0) { - /* we're stopped by the channel's policy */ + if ((sc->flags & SC_FL_RCV_ONCE) || --read_poll <= 0) { + /* we don't expect to read more data */ sc_wont_read(sc); break; } diff --git a/src/stream.c b/src/stream.c index a0007bd088..8097af2634 100644 --- a/src/stream.c +++ b/src/stream.c @@ -921,7 +921,7 @@ static void back_establish(struct stream *s) } } else { - rep->flags |= CF_READ_DONTWAIT; /* a single read is enough to get response headers */ + s->scb->flags |= SC_FL_RCV_ONCE; /* a single read is enough to get response headers */ } rep->analysers |= strm_fe(s)->fe_rsp_ana | s->be->be_rsp_ana;