MEDIUM: connection: make conn_drain() perform more controls
Currently si_idle_conn_null_cb() has to perform some low-level checks
over the file descriptor and the connection configuration that should
only belong to conn_drain(). Let's move these controls there. The
function now automatically checks for errors and hangups on the file
descriptor for example, and disables recv polling if there's no drain
function at the control layer.
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 3fc1e56..8450117 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -497,20 +497,7 @@
*/
static void si_idle_conn_null_cb(struct connection *conn)
{
- 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)) {
- 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);
+ conn_drain(conn);
}
/* Callback to be used by connection I/O handlers when some activity is detected