Now we can more safely rely on the connection state to decide how to
drain and what to do when data are drained. Callers don't need to
manipulate the file descriptor's state anymore.
Note that it also removes the need for the fix
ea90063 ("BUG/MEDIUM:
stream-int: fix the keep-alive idle connection handler") since conn_drain()
correctly sets the polling flags.
/* We're here because nobody wants to handle the error, so we
* sure want to abort the hard way.
*/
- if (conn_ctrl_ready(conn) && !(conn->flags & CO_FL_SOCK_RD_SH)) {
- if (!(conn->flags & CO_FL_WAIT_RD) && conn->ctrl->drain && conn->ctrl->drain(conn->t.sock.fd) > 0)
- fdtab[conn->t.sock.fd].linger_risk = 0;
- }
+ conn_drain(conn);
conn_force_close(conn);
}
return 0;
* as a failed response coupled with "observe layer7" caused the
* server state to be suddenly changed.
*/
- if (conn_ctrl_ready(conn) && !(conn->flags & CO_FL_SOCK_RD_SH)) {
- if (!(conn->flags & CO_FL_WAIT_RD) && conn->ctrl->drain && conn->ctrl->drain(conn->t.sock.fd) > 0)
- fdtab[conn->t.sock.fd].linger_risk = 0;
- }
+ conn_drain(conn);
conn_force_close(conn);
}
* TCP sockets. We first try to drain possibly pending
* data to avoid this as much as possible.
*/
- if ((conn->flags & CO_FL_CTRL_READY) && conn->ctrl && conn->ctrl->drain)
- conn->ctrl->drain(conn->t.sock.fd);
+ conn_drain(conn);
if (!conn->err_code)
conn->err_code = CO_ER_SSL_HANDSHAKE;
goto out_error;
* TCP sockets. We first try to drain possibly pending
* data to avoid this as much as possible.
*/
- if ((conn->flags & CO_FL_CTRL_READY) && conn->ctrl && conn->ctrl->drain)
- conn->ctrl->drain(conn->t.sock.fd);
+ conn_drain(conn);
if (!conn->err_code)
conn->err_code = CO_ER_SSL_HANDSHAKE;
goto out_error;
if (conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH))
return;
- if ((fdtab[conn->t.sock.fd].ev & (FD_POLL_ERR|FD_POLL_HUP)) ||
- (conn->ctrl->drain && conn->ctrl->drain(conn->t.sock.fd) > 0))
+ if (fdtab[conn->t.sock.fd].ev & (FD_POLL_ERR|FD_POLL_HUP)) {
+ fdtab[conn->t.sock.fd].linger_risk = 0;
conn->flags |= CO_FL_SOCK_RD_SH;
+ }
+ else {
+ conn_drain(conn);
+ }
/* disable draining if we were called and have no drain function */
if (!conn->ctrl->drain)
__conn_data_stop_recv(conn);
- else if (!(conn->flags & CO_FL_SOCK_RD_SH))
- __conn_data_poll_recv(conn);
}
/* Callback to be used by connection I/O handlers when some activity is detected