]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream-int: add a new blocking condition on the remote connection
authorWilly Tarreau <w@1wt.eu>
Thu, 6 Dec 2018 14:24:01 +0000 (15:24 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 Dec 2018 14:24:01 +0000 (15:24 +0100)
There are some situations where we need to wait for the other side to
be connected. None of the current blocking flags support this. It used
to work more or less by accident using the old flags. Let's add a new
flag to mention we're blocking on this, it's removed by si_chk_rcv()
when a connection is established. It should be enough for now.

include/proto/stream_interface.h
include/types/stream_interface.h

index da37f73d3102421d7d9a10cc4ef96a07bc855488..e790c7170058da1e5102c33091c443dbbdde6364 100644 (file)
@@ -266,6 +266,18 @@ static inline void si_rx_chan_blk(struct stream_interface *si)
        si->flags |=  SI_FL_RXBLK_CHAN;
 }
 
+/* Tell a stream interface the other side is connected */
+static inline void si_rx_conn_rdy(struct stream_interface *si)
+{
+       si->flags &= ~SI_FL_RXBLK_CONN;
+}
+
+/* Tell a stream interface it must wait for the other side to connect */
+static inline void si_rx_conn_blk(struct stream_interface *si)
+{
+       si->flags |=  SI_FL_RXBLK_CONN;
+}
+
 /* The stream interface just got the input buffer it was waiting for */
 static inline void si_rx_buff_rdy(struct stream_interface *si)
 {
@@ -418,6 +430,9 @@ static inline void si_shutw(struct stream_interface *si)
  */
 static inline void si_chk_rcv(struct stream_interface *si)
 {
+       if (si->flags & SI_FL_RXBLK_CONN && (si_opposite(si)->state >= SI_ST_EST))
+               si_rx_conn_rdy(si);
+
        if (si_rx_blocked(si) || !si_rx_endp_ready(si))
                return;
 
index d9eeacbf09bdb9fe5331557a9bbde72f099e2ca4..c7334bf9fc220b3bbcb705694fcd1858bb4c58bd 100644 (file)
@@ -80,8 +80,9 @@ enum {
        SI_FL_RXBLK_BUFF = 0x00020000,  /* stream-int waits for a buffer allocation to complete */
        SI_FL_RXBLK_ROOM = 0x00040000,  /* stream-int waits for more buffer room to store incoming data */
        SI_FL_RXBLK_SHUT = 0x00080000,  /* input is now closed, nothing new will ever come */
-       SI_FL_RXBLK_ANY  = 0x000F0000,  /* any of the RXBLK flags above */
-       SI_FL_RX_WAIT_EP = 0x00100000,  /* stream-int waits for more data from the end point */
+       SI_FL_RXBLK_CONN = 0x00100000,  /* other side is not connected */
+       SI_FL_RXBLK_ANY  = 0x001F0000,  /* any of the RXBLK flags above */
+       SI_FL_RX_WAIT_EP = 0x00200000,  /* stream-int waits for more data from the end point */
 };
 
 /* A stream interface has 3 parts :