]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: stconn: rename cs_cant_get() to se_need_more_data()
authorWilly Tarreau <w@1wt.eu>
Wed, 25 May 2022 16:21:43 +0000 (18:21 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 27 May 2022 17:33:35 +0000 (19:33 +0200)
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.

include/haproxy/applet.h
include/haproxy/conn_stream.h
src/applet.c
src/conn_stream.c
src/dns.c
src/flt_spoe.c
src/hlua.c
src/http_client.c
src/peers.c
src/sink.c
src/stream.c

index 35b600b0fd3e403b2e43895bd0bda80afbabafe9..d695d04084833e6b520baeb3c6e153f78994dd54 100644 (file)
@@ -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 <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.
index 2f7b457d424e3cb225904d15780017ac43d49cf2..b48b4f17c21a1f10660e8868bdaa468ca142eae4 100644 (file)
@@ -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 */
index 7e7f47d20869f00cc81433347f72b3a8558cfcd4..834c47943ef53362547b3343f01ee1986c09342a 100644 (file)
@@ -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
index 3e895121070e9c0ff7699703a363a6347769c843..1695541bb93a9a9e6b53fd421da7d8b2e15fa763 100644 (file)
@@ -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;
index 3bb2653a00a1f465e6f5694110e457f96d66a131..69f16bc42b65dc4da6b82805e13a6143a21c7f9c 100644 (file)
--- 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;
index fc41f5222c17472bfecc413c27361a0c744b1bf7..53c8defef3779c701620da389f3b090a6a7c265f 100644 (file)
@@ -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;
index 64a6ae83eeb8c41f5d403caf73e4433c0c036d95..292d8f28a8be19c496f9ccb3897c5fab7691eac5 100644 (file)
@@ -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;
                }
        }
index da774e759c00ca1fe63f915a1bc37b95f83dab33..ee0c69a26081d00e973f18312037b3089dcd0d77 100644 (file)
@@ -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;
index 81af529d786de828b6f3cca0a168ab2a49af9392..ae650a6384255d7132fcba19b27f41799d35ac72 100644 (file)
@@ -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 */
index f8e9404bc02efb42a1eeb821a85d3966ead38f43..4f39c05d0aad48bf6533d44c90e55e489ef3a3fe 100644 (file)
@@ -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;
index 4ca48fe16f295e71605b1f8bb2b55649facb7b36..16456e0cead4f55595ae6a5655d56559bfc8a616 100644 (file)
@@ -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;
 }