]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stconn: Add a connection flag to notify sending data are the last ones
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 20 Feb 2024 07:43:09 +0000 (08:43 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 28 Mar 2024 16:32:55 +0000 (17:32 +0100)
This flag can be use by endpoints to know the data to send, via .snd_buf
callback function are the last ones. It is useful to know a shutdown is
pending but it cannot be delivered while sedning data are not consumed.

include/haproxy/connection-t.h
src/stconn.c

index 00639dd6bc6d94229f458380905494ca88c12244..5adf3cf2dd2cf2f1e2aa97163e64d8a47713e49b 100644 (file)
@@ -278,6 +278,7 @@ enum {
 enum {
        CO_SFL_MSG_MORE    = 0x0001,    /* More data to come afterwards */
        CO_SFL_STREAMER    = 0x0002,    /* Producer is continuously streaming data */
+       CO_SFL_LAST_DATA   = 0x0003,    /* Sent data are the last ones, shutdown is pending */
 };
 
 /* mux->shutr() modes */
index c6515b14e562ed01e50a81f01ff0fd0d47137a28..0383e240484e7d3582f6a5a0ed19b38ac4de70e3 100644 (file)
@@ -1636,6 +1636,9 @@ int sc_conn_send(struct stconn *sc)
                        }
                }
 
+               if ((sc->flags & SC_FL_SHUT_WANTED) && co_data(oc) == c_data(oc))
+                       send_flag |= CO_SFL_LAST_DATA;
+
                ret = conn->mux->snd_buf(sc, &oc->buf, co_data(oc), send_flag);
                if (ret > 0) {
                        did_send = 1;
@@ -2154,7 +2157,12 @@ int sc_applet_send(struct stconn *sc)
        BUG_ON(sc_ep_have_ff_data(sc));
 
        if (co_data(oc)) {
-               ret = appctx_snd_buf(sc, &oc->buf, co_data(oc), 0);
+               unsigned int send_flag = 0;
+
+               if ((sc->flags & SC_FL_SHUT_WANTED) && co_data(oc) == c_data(oc))
+                       send_flag |= CO_SFL_LAST_DATA;
+
+               ret = appctx_snd_buf(sc, &oc->buf, co_data(oc), send_flag);
                if (ret > 0) {
                        did_send = 1;
                        c_rew(oc, ret);