From: Willy Tarreau Date: Fri, 21 Feb 2020 09:34:19 +0000 (+0100) Subject: MINOR: connection: remove the last calls to conn_xprt_{want,stop}_* X-Git-Tag: v2.2-dev3~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1d14c3157aae39cc60a56897335a2b01c95bd5a;p=thirdparty%2Fhaproxy.git MINOR: connection: remove the last calls to conn_xprt_{want,stop}_* The last few calls to conn_xprt_{want,stop}_{recv,send} in the central connection code were replaced with their strictly exact equivalent fd_*, adding the call to conn_ctrl_ready() when it was missing. --- diff --git a/include/proto/connection.h b/include/proto/connection.h index 7fb41af1d5..e4f4de90c3 100644 --- a/include/proto/connection.h +++ b/include/proto/connection.h @@ -245,12 +245,13 @@ static inline void conn_xprt_stop_both(struct connection *c) static inline void conn_sock_read0(struct connection *c) { c->flags |= CO_FL_SOCK_RD_SH; - __conn_xprt_stop_recv(c); - /* we don't risk keeping ports unusable if we found the - * zero from the other side. - */ - if (conn_ctrl_ready(c)) + if (conn_ctrl_ready(c)) { + fd_stop_recv(c->handle.fd); + /* we don't risk keeping ports unusable if we found the + * zero from the other side. + */ fdtab[c->handle.fd].linger_risk = 0; + } } /* write shutdown, indication that the upper layer is not willing to send @@ -261,18 +262,20 @@ static inline void conn_sock_read0(struct connection *c) static inline void conn_sock_shutw(struct connection *c, int clean) { c->flags |= CO_FL_SOCK_WR_SH; - __conn_xprt_stop_send(c); - - /* don't perform a clean shutdown if we're going to reset or - * if the shutr was already received. - */ - if (conn_ctrl_ready(c) && !(c->flags & CO_FL_SOCK_RD_SH) && clean) - shutdown(c->handle.fd, SHUT_WR); + if (conn_ctrl_ready(c)) { + fd_stop_send(c->handle.fd); + /* don't perform a clean shutdown if we're going to reset or + * if the shutr was already received. + */ + if (!(c->flags & CO_FL_SOCK_RD_SH) && clean) + shutdown(c->handle.fd, SHUT_WR); + } } static inline void conn_xprt_shutw(struct connection *c) { - __conn_xprt_stop_send(c); + if (conn_ctrl_ready(c)) + fd_stop_send(c->handle.fd); /* clean data-layer shutdown */ if (c->xprt && c->xprt->shutw) @@ -281,7 +284,8 @@ static inline void conn_xprt_shutw(struct connection *c) static inline void conn_xprt_shutw_hard(struct connection *c) { - __conn_xprt_stop_send(c); + if (conn_ctrl_ready(c)) + fd_stop_send(c->handle.fd); /* unclean data-layer shutdown */ if (c->xprt && c->xprt->shutw) diff --git a/src/connection.c b/src/connection.c index 713bc12fa5..c58db58749 100644 --- a/src/connection.c +++ b/src/connection.c @@ -106,7 +106,7 @@ void conn_fd_handler(int fd) conn->subs = NULL; } else io_available = 1; - __conn_xprt_stop_send(conn); + fd_stop_send(fd); } /* The data transfer starts here and stops on error and handshakes. Note @@ -126,7 +126,7 @@ void conn_fd_handler(int fd) conn->subs = NULL; } else io_available = 1; - __conn_xprt_stop_recv(conn); + fd_stop_recv(fd); } leave: @@ -249,8 +249,8 @@ int conn_fd_check(struct connection *conn) return 0; wait: - __conn_xprt_want_send(conn); fd_cant_send(fd); + fd_want_send(fd); return 0; } @@ -324,12 +324,13 @@ int conn_unsubscribe(struct connection *conn, void *xprt_ctx, int event_type, st if (!es->events) conn->subs = NULL; - if (event_type & SUB_RETRY_RECV) - __conn_xprt_stop_recv(conn); - - if (event_type & SUB_RETRY_SEND) - __conn_xprt_stop_send(conn); + if (conn_ctrl_ready(conn)) { + if (event_type & SUB_RETRY_RECV) + fd_stop_recv(conn->handle.fd); + if (event_type & SUB_RETRY_SEND) + fd_stop_send(conn->handle.fd); + } return 0; } @@ -346,12 +347,13 @@ int conn_subscribe(struct connection *conn, void *xprt_ctx, int event_type, stru conn->subs = es; es->events |= event_type; - if (event_type & SUB_RETRY_RECV) - __conn_xprt_want_recv(conn); - - if (event_type & SUB_RETRY_SEND) - __conn_xprt_want_send(conn); + if (conn_ctrl_ready(conn)) { + if (event_type & SUB_RETRY_RECV) + fd_want_recv(conn->handle.fd); + if (event_type & SUB_RETRY_SEND) + fd_want_send(conn->handle.fd); + } return 0; }