]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream-int/conn-stream Move si_is_conn_error() in the conn-stream scope
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 1 Apr 2022 15:15:10 +0000 (17:15 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 13 Apr 2022 13:10:15 +0000 (15:10 +0200)
si_is_conn_error() is renamed as cs_is_conn_erro() and updated to manipulate
a conn-stream instead of a stream-interface.

include/haproxy/cs_utils.h
include/haproxy/stream_interface.h
src/conn_stream.c
src/stream_interface.c

index 64b5e855bdfc15db36786a3b9149a512e7f97c1e..257fcd3af297fe4d2a2d8e5c639c5f35f171bc63 100644 (file)
@@ -123,6 +123,25 @@ static inline int cs_conn_ready(struct conn_stream *cs)
 }
 
 
+/* The conn-stream is only responsible for the connection during the early
+ * states, before plugging a mux. Thus it should only care about CO_FL_ERROR
+ * before CS_ST_EST, and after that it must absolutely ignore it since the mux
+ * may hold pending data. This function returns true if such an error was
+ * reported. Both the CS and the CONN must be valid.
+ */
+static inline int cs_is_conn_error(const struct conn_stream *cs)
+{
+       struct connection *conn;
+
+       if (cs->state >= CS_ST_EST)
+               return 0;
+
+       conn = __cs_conn(cs);
+       BUG_ON(!conn);
+       return !!(conn->flags & CO_FL_ERROR);
+}
+
+
 /* Returns the source address of the conn-stream and, if not set, fallbacks on
  * the session for frontend CS and the server connection for the backend CS. It
  * returns a const address on success or NULL on failure.
index 8f9c98fd194df485c6de554463b4229557fdee29..5c6436705f9c670132f80b4673a12bd4ad6ba9d8 100644 (file)
@@ -261,24 +261,6 @@ static inline int si_alloc_ibuf(struct stream_interface *si, struct buffer_wait
        return ret;
 }
 
-/* The stream interface is only responsible for the connection during the early
- * states, before plugging a mux. Thus it should only care about CO_FL_ERROR
- * before CS_ST_EST, and after that it must absolutely ignore it since the mux
- * may hold pending data. This function returns true if such an error was
- * reported. Both the CS and the CONN must be valid.
- */
-static inline int si_is_conn_error(const struct stream_interface *si)
-{
-       struct connection *conn;
-
-       if (si->cs->state >= CS_ST_EST)
-               return 0;
-
-       conn = __cs_conn(si->cs);
-       BUG_ON(!conn);
-       return !!(conn->flags & CO_FL_ERROR);
-}
-
 #endif /* _HAPROXY_STREAM_INTERFACE_H */
 
 /*
index 0a2edf12d1b33bf07fec0ea7792b1934d3cc61af..1bfdace73564552fafef185590e2eaa419f53aab 100644 (file)
@@ -730,7 +730,7 @@ static void cs_app_chk_snd_conn(struct conn_stream *cs)
        if (!(cs->wait_event.events & SUB_RETRY_SEND) && !channel_is_empty(cs_oc(cs)))
                cs_conn_send(cs);
 
-       if (cs->endp->flags & (CS_EP_ERROR|CS_EP_ERR_PENDING) || si_is_conn_error(cs->si)) {
+       if (cs->endp->flags & (CS_EP_ERROR|CS_EP_ERR_PENDING) || cs_is_conn_error(cs)) {
                /* Write error on the file descriptor */
                if (cs->state >= CS_ST_CON)
                        cs->endp->flags |= CS_EP_ERROR;
index 11cd3395b2d2920698325463052ed1f421089f10..85c9398ffb929cc18bdde57e85f1458db0ee7f1a 100644 (file)
@@ -249,7 +249,7 @@ int cs_conn_process(struct conn_stream *cs)
         */
 
        if (cs->state >= CS_ST_CON) {
-               if (si_is_conn_error(cs->si))
+               if (cs_is_conn_error(cs))
                        cs->endp->flags |= CS_EP_ERROR;
        }
 
@@ -320,7 +320,7 @@ int cs_conn_send(struct conn_stream *cs)
        int ret;
        int did_send = 0;
 
-       if (cs->endp->flags & (CS_EP_ERROR|CS_EP_ERR_PENDING) || si_is_conn_error(cs->si)) {
+       if (cs->endp->flags & (CS_EP_ERROR|CS_EP_ERR_PENDING) || cs_is_conn_error(cs)) {
                /* We're probably there because the tasklet was woken up,
                 * but process_stream() ran before, detected there were an
                 * error and put the si back to CS_ST_TAR. There's still