]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: connection: remove conn_{data,sock}_poll_{recv,send}
authorWilly Tarreau <w@1wt.eu>
Wed, 22 Jan 2014 19:02:06 +0000 (20:02 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 25 Jan 2014 23:42:30 +0000 (00:42 +0100)
We simply remove these functions and replace their calls with the
appropriate ones :

  - if we're in the data phase, we can simply report wait on the FD
  - if we're in the socket phase, we may also have to signal the
    desire to read/write on the socket because it might not be
    active yet.

include/proto/connection.h
src/connection.c
src/proto_tcp.c
src/raw_sock.c
src/ssl_sock.c
src/stream_interface.c

index 9954619be652abf5c0a20b3539bcefbff68dcc91..0bec98e44d5448c07fc95c2a98178cda9d5284d8 100644 (file)
@@ -282,12 +282,6 @@ static inline void __conn_data_stop_recv(struct connection *c)
        c->flags &= ~CO_FL_DATA_RD_ENA;
 }
 
-static inline void __conn_data_poll_recv(struct connection *c)
-{
-       c->flags |= CO_FL_DATA_RD_ENA;
-       fd_cant_recv(c->t.sock.fd);
-}
-
 static inline void __conn_data_want_send(struct connection *c)
 {
        c->flags |= CO_FL_DATA_WR_ENA;
@@ -298,12 +292,6 @@ static inline void __conn_data_stop_send(struct connection *c)
        c->flags &= ~CO_FL_DATA_WR_ENA;
 }
 
-static inline void __conn_data_poll_send(struct connection *c)
-{
-       c->flags |= CO_FL_DATA_WR_ENA;
-       fd_cant_send(c->t.sock.fd);
-}
-
 static inline void __conn_data_stop_both(struct connection *c)
 {
        c->flags &= ~(CO_FL_DATA_WR_ENA | CO_FL_DATA_RD_ENA);
@@ -321,12 +309,6 @@ static inline void conn_data_stop_recv(struct connection *c)
        conn_cond_update_data_polling(c);
 }
 
-static inline void conn_data_poll_recv(struct connection *c)
-{
-       __conn_data_poll_recv(c);
-       conn_cond_update_data_polling(c);
-}
-
 static inline void conn_data_want_send(struct connection *c)
 {
        __conn_data_want_send(c);
@@ -339,12 +321,6 @@ static inline void conn_data_stop_send(struct connection *c)
        conn_cond_update_data_polling(c);
 }
 
-static inline void conn_data_poll_send(struct connection *c)
-{
-       __conn_data_poll_send(c);
-       conn_cond_update_data_polling(c);
-}
-
 static inline void conn_data_stop_both(struct connection *c)
 {
        __conn_data_stop_both(c);
@@ -366,12 +342,6 @@ static inline void __conn_sock_stop_recv(struct connection *c)
        c->flags &= ~CO_FL_SOCK_RD_ENA;
 }
 
-static inline void __conn_sock_poll_recv(struct connection *c)
-{
-       c->flags |= CO_FL_SOCK_RD_ENA;
-       fd_cant_recv(c->t.sock.fd);
-}
-
 static inline void __conn_sock_want_send(struct connection *c)
 {
        c->flags |= CO_FL_SOCK_WR_ENA;
@@ -382,12 +352,6 @@ static inline void __conn_sock_stop_send(struct connection *c)
        c->flags &= ~CO_FL_SOCK_WR_ENA;
 }
 
-static inline void __conn_sock_poll_send(struct connection *c)
-{
-       c->flags |= CO_FL_SOCK_WR_ENA;
-       fd_cant_send(c->t.sock.fd);
-}
-
 static inline void __conn_sock_stop_both(struct connection *c)
 {
        c->flags &= ~(CO_FL_SOCK_WR_ENA | CO_FL_SOCK_RD_ENA);
@@ -405,12 +369,6 @@ static inline void conn_sock_stop_recv(struct connection *c)
        conn_cond_update_sock_polling(c);
 }
 
-static inline void conn_sock_poll_recv(struct connection *c)
-{
-       __conn_sock_poll_recv(c);
-       conn_cond_update_sock_polling(c);
-}
-
 static inline void conn_sock_want_send(struct connection *c)
 {
        __conn_sock_want_send(c);
@@ -423,12 +381,6 @@ static inline void conn_sock_stop_send(struct connection *c)
        conn_cond_update_sock_polling(c);
 }
 
-static inline void conn_sock_poll_send(struct connection *c)
-{
-       __conn_sock_poll_send(c);
-       conn_cond_update_sock_polling(c);
-}
-
 static inline void conn_sock_stop_both(struct connection *c)
 {
        __conn_sock_stop_both(c);
@@ -574,8 +526,6 @@ static inline void conn_attach(struct connection *conn, void *owner, const struc
  */
 static inline int conn_drain(struct connection *conn)
 {
-       int ret;
-
        if (!conn_ctrl_ready(conn))
                return 1;
 
@@ -588,11 +538,7 @@ static inline int conn_drain(struct connection *conn)
        if (!conn->ctrl->drain)
                return 0;
 
-       ret = conn->ctrl->drain(conn->t.sock.fd);
-       if (ret < 0)
-               __conn_data_poll_recv(conn);
-
-       if (ret <= 0)
+       if (conn->ctrl->drain(conn->t.sock.fd) <= 0)
                return 0;
 
        conn->flags |= CO_FL_SOCK_RD_SH;
index 0056ec0a6f4905b792b2c51b15f1c02d4ccbee6d..2538cc52155677059f69529bb2f61f277abc373c 100644 (file)
@@ -261,7 +261,7 @@ int conn_recv_proxy(struct connection *conn, int flag)
                        if (errno == EINTR)
                                continue;
                        if (errno == EAGAIN) {
-                               __conn_sock_poll_recv(conn);
+                               fd_cant_recv(conn->t.sock.fd);
                                return 0;
                        }
                        goto recv_abort;
index 4460bb437048c625f0b55c3843c5ca2bde005c7c..cb10661409d9a27e56841bcda9cfe7b5000882c4 100644 (file)
@@ -657,7 +657,7 @@ int tcp_connect_probe(struct connection *conn)
        if (connect(fd, (struct sockaddr *)&conn->addr.to, get_addr_len(&conn->addr.to)) < 0) {
                if (errno == EALREADY || errno == EINPROGRESS) {
                        __conn_sock_stop_recv(conn);
-                       __conn_sock_poll_send(conn);
+                       fd_cant_send(fd);
                        return 0;
                }
 
index 2e3a0cb9ab5bc3f09b0f84059c5030013a2fed1b..3d4278146a82b9635dc41999cac8dfe45c48809e 100644 (file)
@@ -145,7 +145,7 @@ int raw_sock_to_pipe(struct connection *conn, struct pipe *pipe, unsigned int co
 #ifndef ASSUME_SPLICE_WORKS
                                if (splice_detects_close)
 #endif
-                                       __conn_data_poll_recv(conn); /* we know for sure that it's EAGAIN */
+                                       fd_cant_recv(conn->t.sock.fd); /* we know for sure that it's EAGAIN */
                                break;
                        }
                        else if (errno == ENOSYS || errno == EINVAL || errno == EBADF) {
@@ -203,7 +203,7 @@ int raw_sock_from_pipe(struct connection *conn, struct pipe *pipe)
 
                if (ret <= 0) {
                        if (ret == 0 || errno == EAGAIN) {
-                               __conn_data_poll_send(conn);
+                               fd_cant_send(conn->t.sock.fd);
                                break;
                        }
                        else if (errno == EINTR)
@@ -298,7 +298,7 @@ static int raw_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
                        goto read0;
                }
                else if (errno == EAGAIN) {
-                       __conn_data_poll_recv(conn);
+                       fd_cant_recv(conn->t.sock.fd);
                        break;
                }
                else if (errno != EINTR) {
@@ -376,7 +376,7 @@ static int raw_sock_from_buf(struct connection *conn, struct buffer *buf, int fl
                }
                else if (ret == 0 || errno == EAGAIN || errno == ENOTCONN) {
                        /* nothing written, we need to poll for write first */
-                       __conn_data_poll_send(conn);
+                       fd_cant_send(conn->t.sock.fd);
                        break;
                }
                else if (errno != EINTR) {
index 0cfcca798bd7fab87194c63979c74606dbbd079d..d30a8eb88c5472313c9de9937804381cbf128b0b 100644 (file)
@@ -1191,7 +1191,8 @@ int ssl_sock_handshake(struct connection *conn, unsigned int flag)
                        if (ret == SSL_ERROR_WANT_WRITE) {
                                /* SSL handshake needs to write, L4 connection may not be ready */
                                __conn_sock_stop_recv(conn);
-                               __conn_sock_poll_send(conn);
+                               __conn_sock_want_send(conn);
+                               fd_cant_send(conn->t.sock.fd);
                                return 0;
                        }
                        else if (ret == SSL_ERROR_WANT_READ) {
@@ -1206,7 +1207,8 @@ int ssl_sock_handshake(struct connection *conn, unsigned int flag)
                                if (conn->flags & CO_FL_WAIT_L4_CONN)
                                        conn->flags &= ~CO_FL_WAIT_L4_CONN;
                                __conn_sock_stop_send(conn);
-                               __conn_sock_poll_recv(conn);
+                               __conn_sock_want_recv(conn);
+                               fd_cant_recv(conn->t.sock.fd);
                                return 0;
                        }
                        else if (ret == SSL_ERROR_SYSCALL) {
@@ -1249,7 +1251,8 @@ int ssl_sock_handshake(struct connection *conn, unsigned int flag)
                if (ret == SSL_ERROR_WANT_WRITE) {
                        /* SSL handshake needs to write, L4 connection may not be ready */
                        __conn_sock_stop_recv(conn);
-                       __conn_sock_poll_send(conn);
+                       __conn_sock_want_send(conn);
+                       fd_cant_send(conn->t.sock.fd);
                        return 0;
                }
                else if (ret == SSL_ERROR_WANT_READ) {
@@ -1257,7 +1260,8 @@ int ssl_sock_handshake(struct connection *conn, unsigned int flag)
                        if (conn->flags & CO_FL_WAIT_L4_CONN)
                                conn->flags &= ~CO_FL_WAIT_L4_CONN;
                        __conn_sock_stop_send(conn);
-                       __conn_sock_poll_recv(conn);
+                       __conn_sock_want_recv(conn);
+                       fd_cant_recv(conn->t.sock.fd);
                        return 0;
                }
                else if (ret == SSL_ERROR_SYSCALL) {
@@ -1404,7 +1408,7 @@ static int ssl_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
                                        break;
                                }
                                /* we need to poll for retry a read later */
-                               __conn_data_poll_recv(conn);
+                               fd_cant_recv(conn->t.sock.fd);
                                break;
                        }
                        /* otherwise it's a real error */
@@ -1485,7 +1489,7 @@ static int ssl_sock_from_buf(struct connection *conn, struct buffer *buf, int fl
                                        break;
                                }
                                /* we need to poll to retry a write later */
-                               __conn_data_poll_send(conn);
+                               fd_cant_send(conn->t.sock.fd);
                                break;
                        }
                        else if (ret == SSL_ERROR_WANT_READ) {
index 063c1731d3ad0bc036e573a1d6969dac702cf7be..6096dd74987fe3f55efe0b118c2a988b85de0c53 100644 (file)
@@ -487,7 +487,7 @@ int conn_si_send_proxy(struct connection *conn, unsigned int flag)
 
  out_wait:
        __conn_sock_stop_recv(conn);
-       __conn_sock_poll_send(conn);
+       fd_cant_send(conn->t.sock.fd);
        return 0;
 }