From: Christopher Faulet Date: Fri, 1 Apr 2022 15:15:10 +0000 (+0200) Subject: MINOR: stream-int/conn-stream Move si_is_conn_error() in the conn-stream scope X-Git-Tag: v2.6-dev6~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=158f33615de5a257a022b0972a2e68d4eb888741;p=thirdparty%2Fhaproxy.git MINOR: stream-int/conn-stream Move si_is_conn_error() in the conn-stream scope si_is_conn_error() is renamed as cs_is_conn_erro() and updated to manipulate a conn-stream instead of a stream-interface. --- diff --git a/include/haproxy/cs_utils.h b/include/haproxy/cs_utils.h index 64b5e855bd..257fcd3af2 100644 --- a/include/haproxy/cs_utils.h +++ b/include/haproxy/cs_utils.h @@ -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. diff --git a/include/haproxy/stream_interface.h b/include/haproxy/stream_interface.h index 8f9c98fd19..5c6436705f 100644 --- a/include/haproxy/stream_interface.h +++ b/include/haproxy/stream_interface.h @@ -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 */ /* diff --git a/src/conn_stream.c b/src/conn_stream.c index 0a2edf12d1..1bfdace735 100644 --- a/src/conn_stream.c +++ b/src/conn_stream.c @@ -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; diff --git a/src/stream_interface.c b/src/stream_interface.c index 11cd3395b2..85c9398ffb 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -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