MEDIUM: connection: remove conn_{data,sock}_poll_{recv,send}
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.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index 9954619..0bec98e 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -282,12 +282,6 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 int conn_drain(struct connection *conn)
{
- int ret;
-
if (!conn_ctrl_ready(conn))
return 1;
@@ -588,11 +538,7 @@
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;
diff --git a/src/connection.c b/src/connection.c
index 0056ec0..2538cc5 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -261,7 +261,7 @@
if (errno == EINTR)
continue;
if (errno == EAGAIN) {
- __conn_sock_poll_recv(conn);
+ fd_cant_recv(conn->t.sock.fd);
return 0;
}
goto recv_abort;
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 4460bb4..cb10661 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -657,7 +657,7 @@
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;
}
diff --git a/src/raw_sock.c b/src/raw_sock.c
index 2e3a0cb..3d42781 100644
--- a/src/raw_sock.c
+++ b/src/raw_sock.c
@@ -145,7 +145,7 @@
#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 @@
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 @@
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 @@
}
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) {
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index 0cfcca7..d30a8eb 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -1191,7 +1191,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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) {
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 063c173..6096dd7 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -487,7 +487,7 @@
out_wait:
__conn_sock_stop_recv(conn);
- __conn_sock_poll_send(conn);
+ fd_cant_send(conn->t.sock.fd);
return 0;
}