From: Willy Tarreau Date: Wed, 25 May 2022 16:21:43 +0000 (+0200) Subject: CLEANUP: stconn: rename cs_cant_get() to se_need_more_data() X-Git-Tag: v2.6-dev12~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=90e8b455b7df814fd2357bc11763852a4f1232a2;p=thirdparty%2Fhaproxy.git CLEANUP: stconn: rename cs_cant_get() to se_need_more_data() An equivalent applet_need_more_data() was added as well since that function is mostly used from applet code. It makes it much clearer that the applet is waiting for data from the stream layer. --- diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index 35b600b0fd..d695d04084 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -160,6 +160,15 @@ static inline void applet_wont_consume(struct appctx *appctx) se_fl_clr(appctx->sedesc, SE_FL_WILL_CONSUME); } +/* The applet indicates that it's willing to consume data from the stream's + * output buffer, but that there's not enough, so it doesn't want to be woken + * up until more are presented. + */ +static inline void applet_need_more_data(struct appctx *appctx) +{ + se_fl_set(appctx->sedesc, SE_FL_WILL_CONSUME | SE_FL_WAIT_DATA); +} + /* writes chunk into the input channel of the stream attached to this * appctx's endpoint, and marks the SC_FL_NEED_ROOM on a channel full error. * See ci_putchk() for the list of return codes. diff --git a/include/haproxy/conn_stream.h b/include/haproxy/conn_stream.h index 2f7b457d42..b48b4f17c2 100644 --- a/include/haproxy/conn_stream.h +++ b/include/haproxy/conn_stream.h @@ -389,10 +389,13 @@ static inline void se_wont_consume(struct sedesc *se) se_fl_clr(se, SE_FL_WILL_CONSUME); } -/* Report that a stream connector failed to get some data from the output buffer */ -static inline void cs_cant_get(struct stconn *cs) +/* The stream endpoint indicates that it's willing to consume data from the + * stream's output buffer, but that there's not enough, so it doesn't want to + * be woken up until more are presented. + */ +static inline void se_need_more_data(struct sedesc *se) { - sc_ep_set(cs, SE_FL_WILL_CONSUME | SE_FL_WAIT_DATA); + se_fl_set(se, SE_FL_WILL_CONSUME | SE_FL_WAIT_DATA); } #endif /* _HAPROXY_CONN_STREAM_H */ diff --git a/src/applet.c b/src/applet.c index 7e7f47d208..834c47943e 100644 --- a/src/applet.c +++ b/src/applet.c @@ -218,7 +218,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state) * put, it's up to it to change this if needed. This ensures * that one applet which ignores any event will not spin. */ - cs_cant_get(cs); + applet_need_more_data(app); applet_have_no_more_data(app); /* Now we'll try to allocate the input buffer. We wake up the applet in diff --git a/src/conn_stream.c b/src/conn_stream.c index 3e89512107..1695541bb9 100644 --- a/src/conn_stream.c +++ b/src/conn_stream.c @@ -489,7 +489,7 @@ struct appctx *cs_applet_create(struct stconn *cs, struct applet *app) return NULL; cs_attach_applet(cs, appctx); appctx->t->nice = __sc_strm(cs)->task->nice; - cs_cant_get(cs); + applet_need_more_data(appctx); appctx_wakeup(appctx); cs->state = SC_ST_RDY; diff --git a/src/dns.c b/src/dns.c index 3bb2653a00..69f16bc42b 100644 --- a/src/dns.c +++ b/src/dns.c @@ -472,7 +472,7 @@ static void dns_session_io_handler(struct appctx *appctx) * to be notified whenever the connection completes. */ if (cs_opposite(cs)->state < SC_ST_EST) { - cs_cant_get(cs); + applet_need_more_data(appctx); se_need_remote_conn(appctx->sedesc); applet_have_more_data(appctx); return; diff --git a/src/flt_spoe.c b/src/flt_spoe.c index fc41f5222c..53c8defef3 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -1242,7 +1242,7 @@ spoe_init_appctx(struct appctx *appctx) stream_set_backend(s, agent->b.be); /* applet is waiting for data */ - cs_cant_get(s->scf); + applet_need_more_data(appctx); s->do_log = NULL; s->res.flags |= CF_READ_DONTWAIT; diff --git a/src/hlua.c b/src/hlua.c index 64a6ae83ee..292d8f28a8 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -1956,7 +1956,7 @@ static void hlua_socket_handler(struct appctx *appctx) * to be notified whenever the connection completes. */ if (cs_opposite(cs)->state < SC_ST_EST) { - cs_cant_get(cs); + applet_need_more_data(appctx); se_need_remote_conn(appctx->sedesc); applet_have_more_data(appctx); return; @@ -2858,7 +2858,7 @@ __LJMP static int hlua_socket_connect(struct lua_State *L) /* inform the stream that we want to be notified whenever the * connection completes. */ - cs_cant_get(s->scf); + applet_need_more_data(appctx); applet_have_more_data(appctx); appctx_wakeup(appctx); @@ -4491,7 +4491,7 @@ __LJMP static int hlua_applet_tcp_getline_yield(lua_State *L, int status, lua_KC /* Data not yet available. return yield. */ if (ret == 0) { - cs_cant_get(cs); + applet_need_more_data(luactx->appctx); MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_tcp_getline_yield, TICK_ETERNITY, 0)); } @@ -4546,7 +4546,7 @@ __LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KCont /* Data not yet available. return yield. */ if (ret == 0) { - cs_cant_get(cs); + applet_need_more_data(luactx->appctx); MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_tcp_recv_yield, TICK_ETERNITY, 0)); } @@ -4569,7 +4569,7 @@ __LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KCont luaL_addlstring(&luactx->b, blk1, len1); luaL_addlstring(&luactx->b, blk2, len2); co_skip(sc_oc(cs), len1 + len2); - cs_cant_get(cs); + applet_need_more_data(luactx->appctx); MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_tcp_recv_yield, TICK_ETERNITY, 0)); } else { @@ -4593,7 +4593,7 @@ __LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KCont if (len > 0) { lua_pushinteger(L, len); lua_replace(L, 2); - cs_cant_get(cs); + applet_need_more_data(luactx->appctx); MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_tcp_recv_yield, TICK_ETERNITY, 0)); } @@ -5035,7 +5035,7 @@ __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_K htx_to_buf(htx, &req->buf); if (!stop) { - cs_cant_get(cs); + applet_need_more_data(luactx->appctx); MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_http_getline_yield, TICK_ETERNITY, 0)); } @@ -5133,7 +5133,7 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon lua_pushinteger(L, len); lua_replace(L, 2); } - cs_cant_get(cs); + applet_need_more_data(luactx->appctx); MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_http_recv_yield, TICK_ETERNITY, 0)); } @@ -9305,7 +9305,7 @@ static int hlua_applet_tcp_init(struct appctx *ctx) RESET_SAFE_LJMP(hlua); /* Wakeup the applet ASAP. */ - cs_cant_get(cs); + applet_need_more_data(ctx); applet_have_more_data(ctx); return 0; @@ -9502,7 +9502,7 @@ static int hlua_applet_http_init(struct appctx *ctx) RESET_SAFE_LJMP(hlua); /* Wakeup the applet when data is ready for read. */ - cs_cant_get(cs); + applet_need_more_data(ctx); return 0; } @@ -9538,7 +9538,7 @@ void hlua_applet_http_fct(struct appctx *ctx) if (!HLUA_IS_RUNNING(hlua) && !(http_ctx->flags & APPLET_DONE)) { if (!co_data(req)) { - cs_cant_get(cs); + applet_need_more_data(ctx); goto out; } } diff --git a/src/http_client.c b/src/http_client.c index da774e759c..ee0c69a260 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -1018,7 +1018,7 @@ static int httpclient_applet_init(struct appctx *appctx) s->res.flags |= CF_READ_DONTWAIT; /* applet is waiting for data */ - cs_cant_get(s->scf); + applet_need_more_data(appctx); appctx_wakeup(appctx); hc->appctx = appctx; diff --git a/src/peers.c b/src/peers.c index 81af529d78..ae650a6384 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1085,7 +1085,7 @@ static int peer_session_init(struct appctx *appctx) s = appctx_strm(appctx); /* applet is waiting for data */ - cs_cant_get(s->scf); + applet_need_more_data(appctx); appctx_wakeup(appctx); /* initiate an outgoing connection */ diff --git a/src/sink.c b/src/sink.c index f8e9404bc0..4f39c05d0a 100644 --- a/src/sink.c +++ b/src/sink.c @@ -333,7 +333,7 @@ static void sink_forward_io_handler(struct appctx *appctx) * to be notified whenever the connection completes. */ if (cs_opposite(cs)->state < SC_ST_EST) { - cs_cant_get(cs); + applet_need_more_data(appctx); se_need_remote_conn(appctx->sedesc); applet_have_more_data(appctx); return; @@ -473,7 +473,7 @@ static void sink_forward_oc_io_handler(struct appctx *appctx) * to be notified whenever the connection completes. */ if (cs_opposite(cs)->state < SC_ST_EST) { - cs_cant_get(cs); + applet_need_more_data(appctx); se_need_remote_conn(appctx->sedesc); applet_have_more_data(appctx); return; diff --git a/src/stream.c b/src/stream.c index 4ca48fe16f..16456e0cea 100644 --- a/src/stream.c +++ b/src/stream.c @@ -1013,7 +1013,7 @@ enum act_return process_use_service(struct act_rule *rule, struct proxy *px, } /* Now we can schedule the applet. */ - cs_cant_get(s->scb); + applet_need_more_data(appctx); appctx_wakeup(appctx); return ACT_RET_STOP; }