if (!fd_recv_ready(conn->handle.fd))
return 0;
+ conn_refresh_polling_flags(conn);
errno = 0;
/* Under Linux, if FD_POLL_HUP is set, we have reached the end.
if ((fdtab[conn->handle.fd].ev & FD_POLL_ERR) && (conn->flags & CO_FL_WAIT_L4_CONN)) {
conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH;
errno = 0; /* let the caller do a getsockopt() if it wants it */
- return retval;
+ goto leave;
}
}
* We can safely return -1 since there is no
* chance that any data has been piped yet.
*/
- return -1;
+ retval = -1;
+ goto leave;
}
else if (errno == EINTR) {
/* try again */
if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && retval)
conn->flags &= ~CO_FL_WAIT_L4_CONN;
+
+ leave:
+ conn_cond_update_sock_polling(conn);
return retval;
out_read0:
conn_sock_read0(conn);
conn->flags &= ~CO_FL_WAIT_L4_CONN;
- return retval;
+ goto leave;
}
/* Send as many bytes as possible from the pipe to the connection's socket.
if (!fd_send_ready(conn->handle.fd))
return 0;
+ conn_refresh_polling_flags(conn);
done = 0;
while (pipe->data) {
ret = splice(pipe->cons, NULL, conn->handle.fd, NULL, pipe->data,
}
if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done)
conn->flags &= ~CO_FL_WAIT_L4_CONN;
+
+ conn_cond_update_sock_polling(conn);
return done;
}
if (!fd_recv_ready(conn->handle.fd))
return 0;
+ conn_refresh_polling_flags(conn);
errno = 0;
if (unlikely(!(fdtab[conn->handle.fd].ev & FD_POLL_IN))) {
/* report error on POLL_ERR before connection establishment */
if ((fdtab[conn->handle.fd].ev & FD_POLL_ERR) && (conn->flags & CO_FL_WAIT_L4_CONN)) {
conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH;
- return done;
+ goto leave;
}
}
if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done)
conn->flags &= ~CO_FL_WAIT_L4_CONN;
+
+ leave:
+ conn_cond_update_sock_polling(conn);
return done;
read0:
*/
if (unlikely(fdtab[conn->handle.fd].ev & FD_POLL_ERR))
conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH;
- return done;
+ goto leave;
}
if (!fd_send_ready(conn->handle.fd))
return 0;
+ conn_refresh_polling_flags(conn);
done = 0;
/* send the largest possible block. For this we perform only one call
* to send() unless the buffer wraps and we exactly fill the first hunk,
}
if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done)
conn->flags &= ~CO_FL_WAIT_L4_CONN;
+
+ conn_cond_update_sock_polling(conn);
return done;
}