]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream-int: add new functions si_{rx,tx}_{blocked,endp_ready}()
authorWilly Tarreau <w@1wt.eu>
Wed, 14 Nov 2018 13:01:40 +0000 (14:01 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 18 Nov 2018 20:41:46 +0000 (21:41 +0100)
The first ones are used to figure if a direction is blocked on the
stream interface for anything but the end point. The second ones are
used to detect if the end point is ready to receive/transmit. They
should be used instead of directly fiddling with the existing bits.

include/proto/stream_interface.h

index ad0fe031e8577201ac0e8a9bf8845d21764ab6a5..6d463815572d448f9ebed55a18c2424437fcb436 100644 (file)
@@ -247,6 +247,18 @@ static inline void si_applet_release(struct stream_interface *si)
                appctx->applet->release(appctx);
 }
 
+/* Returns non-zero if the stream interface's Rx path is blocked */
+static inline int si_rx_blocked(const struct stream_interface *si)
+{
+       return !!(si->flags & SI_FL_RXBLK_ANY);
+}
+
+/* Returns non-zero if the stream interface's endpoint is ready to receive */
+static inline int si_rx_endp_ready(const struct stream_interface *si)
+{
+       return !(si->flags & SI_FL_RX_WAIT_EP);
+}
+
 /* Report that a stream interface wants to put some data into the input buffer */
 static inline void si_want_put(struct stream_interface *si)
 {
@@ -271,6 +283,18 @@ static inline void si_done_put(struct stream_interface *si)
        si->flags &= ~(SI_FL_WANT_PUT | SI_FL_RXBLK_ROOM);
 }
 
+/* Returns non-zero if the stream interface's Rx path is blocked */
+static inline int si_tx_blocked(const struct stream_interface *si)
+{
+       return !!(si->flags & SI_FL_WAIT_DATA);
+}
+
+/* Returns non-zero if the stream interface's endpoint is ready to transmit */
+static inline int si_tx_endp_ready(const struct stream_interface *si)
+{
+       return (si->flags & SI_FL_WANT_GET);
+}
+
 /* Report that a stream interface wants to get some data from the output buffer */
 static inline void si_want_get(struct stream_interface *si)
 {