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.
This commit is contained in:
parent
310987a038
commit
e1f50c4b02
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user