]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stconn: start to rename cs_rx_endp_{more,done}() to se_have_{no_,}more_data()
authorWilly Tarreau <w@1wt.eu>
Wed, 25 May 2022 13:42:03 +0000 (15:42 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 27 May 2022 17:33:35 +0000 (19:33 +0200)
The analysis of cs_rx_endp_more() showed that the purpose is for a stream
endpoint to inform the connector that it's ready to deliver more data to
that one, and conversely cs_rx_endp_done() that it's done delivering data
so it should not be bothered again for this.

This was modified two ways:
  - the operation is no longer performed on the connector but on the
    endpoint so that there is no more doubt when reading applet code
    about what this rx refers to; it's the endpoint that has more or
    no more data.

  - an applet implementation is also provided and mostly used from
    applet code since it saves the caller from having to access the
    endpoint descriptor.

It's visible that the flag ought to be inverted because some places
have to set it by default for no reason.

13 files changed:
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/map.c
src/ring.c
src/sink.c
src/ssl_ckch.c
src/ssl_crtlist.c
src/stream.c

index eb5e42a07cfcd6595ccb39ba8ae06be72bc13241..9e5e44fd774f3095405dd7d91ebd7419ff5b812f 100644 (file)
@@ -128,6 +128,22 @@ static inline struct stream *appctx_strm(const struct appctx *appctx)
        return __sc_strm(appctx->sedesc->sc);
 }
 
+/* The applet announces it has more data to deliver to the stream's input
+ * buffer.
+ */
+static inline void applet_have_more_data(struct appctx *appctx)
+{
+       se_fl_clr(appctx->sedesc, SE_FL_RX_WAIT_EP);
+}
+
+/* The applet announces it doesn't have more data for the stream's input
+ * buffer.
+ */
+static inline void applet_have_no_more_data(struct appctx *appctx)
+{
+       se_fl_set(appctx->sedesc, SE_FL_RX_WAIT_EP);
+}
+
 /* writes chunk <chunk> into the input channel of the stream attached to this
  * appctx's endpoint, and marks the RXBLK_ROOM on a channel full error. See
  * ci_putchk() for the list of return codes.
index 0418039e2842747c99e46fabab7fd090e8aa4ee0..b98f5db45bd20555726b30b6c16f4af9071bc2d4 100644 (file)
@@ -305,16 +305,20 @@ static inline int cs_rx_endp_ready(const struct stconn *cs)
        return !sc_ep_test(cs, SE_FL_RX_WAIT_EP);
 }
 
-/* The stream connector announces it is ready to try to deliver more data to the input buffer */
-static inline void cs_rx_endp_more(struct stconn *cs)
+/* The stream endpoint announces it has more data to deliver to the stream's
+ * input buffer.
+ */
+static inline void se_have_more_data(struct sedesc *se)
 {
-       sc_ep_clr(cs, SE_FL_RX_WAIT_EP);
+       se_fl_clr(se, SE_FL_RX_WAIT_EP);
 }
 
-/* The stream connector announces it doesn't have more data for the input buffer */
-static inline void cs_rx_endp_done(struct stconn *cs)
+/* The stream endpoint announces it doesn't have more data for the stream's
+ * input buffer.
+ */
+static inline void se_have_no_more_data(struct sedesc *se)
 {
-       sc_ep_set(cs, SE_FL_RX_WAIT_EP);
+       se_fl_set(se, SE_FL_RX_WAIT_EP);
 }
 
 /* The application layer informs a stream connector that it's willing to
index c48d36f616701a572c145e5756750b96393dd690..7330512b0d4881aaa1fded2ce93df0174c0c2fc8 100644 (file)
@@ -219,7 +219,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
         * that one applet which ignores any event will not spin.
         */
        cs_cant_get(cs);
-       cs_rx_endp_done(cs);
+       applet_have_no_more_data(app);
 
        /* Now we'll try to allocate the input buffer. We wake up the applet in
         * all cases. So this is the applet's responsibility to check if this
@@ -228,7 +228,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
         * do if it needs the buffer, it will be called again upon readiness.
         */
        if (!cs_alloc_ibuf(cs, &app->buffer_wait))
-               cs_rx_endp_more(cs);
+               applet_have_more_data(app);
 
        count = co_data(sc_oc(cs));
        app->applet->fct(app);
index b898dd9f753c77278c2573d3ef4abc598e8fee03..9904fba31f31168b537a79cba004f61b129b48f8 100644 (file)
@@ -1588,9 +1588,9 @@ static int sc_conn_recv(struct stconn *cs)
        else if (!cs_rx_blocked(cs) && !(ic->flags & CF_SHUTR)) {
                /* Subscribe to receive events if we're blocking on I/O */
                conn->mux->subscribe(cs, SUB_RETRY_RECV, &cs->wait_event);
-               cs_rx_endp_done(cs);
+               se_have_no_more_data(cs->sedesc);
        } else {
-               cs_rx_endp_more(cs);
+               se_have_more_data(cs->sedesc);
                ret = 1;
        }
        return ret;
@@ -1926,7 +1926,7 @@ static int cs_applet_process(struct stconn *cs)
         * begin blocked by the channel.
         */
        if (cs_rx_blocked(cs) || sc_ep_test(cs, SE_FL_APPLET_NEED_CONN))
-               cs_rx_endp_more(cs);
+               applet_have_more_data(__sc_appctx(cs));
 
        /* update the stream connector, channels, and possibly wake the stream up */
        cs_notify(cs);
index 29e7f3e3fedc87fd6ae56dfc9a54e1090d46ce59..3bb2653a00a1f465e6f5694110e457f96d66a131 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -474,7 +474,7 @@ static void dns_session_io_handler(struct appctx *appctx)
        if (cs_opposite(cs)->state < SC_ST_EST) {
                cs_cant_get(cs);
                se_need_remote_conn(appctx->sedesc);
-               cs_rx_endp_more(cs);
+               applet_have_more_data(appctx);
                return;
        }
 
@@ -649,7 +649,7 @@ static void dns_session_io_handler(struct appctx *appctx)
                BUG_ON(LIST_INLIST(&appctx->wait_entry));
                LIST_APPEND(&ring->waiters, &appctx->wait_entry);
                HA_RWLOCK_WRUNLOCK(DNS_LOCK, &ring->lock);
-               cs_rx_endp_done(cs);
+               applet_have_no_more_data(appctx);
        }
 
 read:
index ac48c0669cefe72e79236bc4570a91f95b90b1a1..90c3e01fa0e6dff924d87cd45533b68169d3283a 100644 (file)
@@ -1194,7 +1194,7 @@ static int
 spoe_wakeup_appctx(struct appctx *appctx)
 {
        cs_want_get(appctx_cs(appctx));
-       cs_rx_endp_more(appctx_cs(appctx));
+       applet_have_more_data(appctx);
        appctx_wakeup(appctx);
        return 1;
 }
@@ -1399,7 +1399,7 @@ spoe_handle_connect_appctx(struct appctx *appctx)
 
        if (!cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST)) {
                /* not connected yet */
-               cs_rx_endp_more(cs);
+               applet_have_more_data(appctx);
                task_wakeup(__sc_strm(cs)->task, TASK_WOKEN_MSG);
                goto stop;
        }
index e9316106b0e2ab32c27cc7184b847c9bb8b0dce0..64a6ae83eeb8c41f5d403caf73e4433c0c036d95 100644 (file)
@@ -1958,7 +1958,7 @@ static void hlua_socket_handler(struct appctx *appctx)
        if (cs_opposite(cs)->state < SC_ST_EST) {
                cs_cant_get(cs);
                se_need_remote_conn(appctx->sedesc);
-               cs_rx_endp_more(cs);
+               applet_have_more_data(appctx);
                return;
        }
 
@@ -1983,7 +1983,7 @@ static void hlua_socket_handler(struct appctx *appctx)
         * to write, so we clear the blocking flag.
         */
        if (notification_registered(&ctx->wake_on_write))
-               cs_rx_endp_more(cs);
+               applet_have_more_data(appctx);
 }
 
 static int hlua_socket_init(struct appctx *appctx)
@@ -2859,7 +2859,7 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
         * connection completes.
         */
        cs_cant_get(s->scf);
-       cs_rx_endp_more(s->scf);
+       applet_have_more_data(appctx);
        appctx_wakeup(appctx);
 
        hlua->gc_count++;
@@ -9306,7 +9306,7 @@ static int hlua_applet_tcp_init(struct appctx *ctx)
 
        /* Wakeup the applet ASAP. */
        cs_cant_get(cs);
-       cs_rx_endp_more(cs);
+       applet_have_more_data(ctx);
 
        return 0;
 }
index b13971092583ff7762ec2997f0a5b53c054bdfbb..3c04eb709a16c96d9db53d7f41702bf5775d908a 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -1023,7 +1023,7 @@ static int cli_io_handler_clear_map(struct appctx *appctx)
 
        if (!finished) {
                /* let's come back later */
-               cs_rx_endp_more(appctx_cs(appctx));
+               applet_have_more_data(appctx);
                return 0;
        }
        return 1;
index 9ab0330db081b466a4ddc62ee456ecd15abb3049..873d0d6bf2d865a987f958d1ff6a3d5ceabe1980 100644 (file)
@@ -378,7 +378,7 @@ int cli_io_handler_show_ring(struct appctx *appctx)
                        HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
                        LIST_APPEND(&ring->waiters, &appctx->wait_entry);
                        HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &ring->lock);
-                       cs_rx_endp_done(cs);
+                       applet_have_no_more_data(appctx);
                        ret = 0;
                }
                /* always drain all the request */
index 6bd30fcac30683f84f429c250f5ebdd1fcdf8f52..f8e9404bc02efb42a1eeb821a85d3966ead38f43 100644 (file)
@@ -335,7 +335,7 @@ static void sink_forward_io_handler(struct appctx *appctx)
        if (cs_opposite(cs)->state < SC_ST_EST) {
                cs_cant_get(cs);
                se_need_remote_conn(appctx->sedesc);
-               cs_rx_endp_more(cs);
+               applet_have_more_data(appctx);
                return;
        }
 
@@ -417,7 +417,7 @@ static void sink_forward_io_handler(struct appctx *appctx)
                HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
                LIST_APPEND(&ring->waiters, &appctx->wait_entry);
                HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &ring->lock);
-               cs_rx_endp_done(cs);
+               applet_have_no_more_data(appctx);
        }
        HA_SPIN_UNLOCK(SFT_LOCK, &sft->lock);
 
@@ -475,7 +475,7 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
        if (cs_opposite(cs)->state < SC_ST_EST) {
                cs_cant_get(cs);
                se_need_remote_conn(appctx->sedesc);
-               cs_rx_endp_more(cs);
+               applet_have_more_data(appctx);
                return;
        }
 
@@ -561,7 +561,7 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
                HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
                LIST_APPEND(&ring->waiters, &appctx->wait_entry);
                HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &ring->lock);
-               cs_rx_endp_done(cs);
+               applet_have_no_more_data(appctx);
        }
        HA_SPIN_UNLOCK(SFT_LOCK, &sft->lock);
 
index afcc6ad7babbae8606c19f272a4bdddd54e70f3e..1accf60f199ad82ed6a46560858b4340d27d3370 100644 (file)
@@ -2144,7 +2144,7 @@ yield:
        /* store the state */
        applet_putchk(appctx, trash);
        free_trash_chunk(trash);
-       cs_rx_endp_more(cs); /* let's come back later */
+       applet_have_more_data(appctx); /* let's come back later */
        return 0; /* should come back */
 
 error:
@@ -2930,7 +2930,7 @@ yield:
        /* store the state */
        applet_putchk(appctx, trash);
        free_trash_chunk(trash);
-       cs_rx_endp_more(cs); /* let's come back later */
+       applet_have_more_data(appctx); /* let's come back later */
        return 0; /* should come back */
 
 error:
index c06f3acde255ee214ba779cff9cac02b49c39675..e4297906aab03abf67cdd8be1101a5c1164f7993 100644 (file)
@@ -1153,7 +1153,7 @@ yield:
        /* store the state */
        applet_putchk(appctx, trash);
        free_trash_chunk(trash);
-       cs_rx_endp_more(cs); /* let's come back later */
+       applet_have_more_data(appctx); /* let's come back later */
        return 0; /* should come back */
 
 error:
index c05f039c77de597bef48a48c92b8d61e23be3c2f..64e2dd0e8d6c7112f0b466d8f0b229b19890c898 100644 (file)
@@ -917,7 +917,7 @@ static void back_establish(struct stream *s)
 
        rep->analysers |= strm_fe(s)->fe_rsp_ana | s->be->be_rsp_ana;
 
-       cs_rx_endp_more(s->scb);
+       se_have_more_data(s->scb->sedesc);
        rep->flags |= CF_READ_ATTACHED; /* producer is now attached */
        if (conn) {
                /* real connections have timeouts
@@ -1476,7 +1476,7 @@ int stream_set_http_mode(struct stream *s, const struct mux_proto_list *mux_prot
 
        conn = sc_conn(cs);
        if (conn) {
-               cs_rx_endp_more(s->scf);
+               se_have_more_data(s->scf->sedesc);
                /* Make sure we're unsubscribed, the the new
                 * mux will probably want to subscribe to
                 * the underlying XPRT