MINOR: connection: add simple functions to report connection readiness
conn_xprt_ready() reports if the transport layer is ready.
conn_ctrl_ready() reports if the control layer is ready.
The stream interface uses si_conn_ready() to report that the
underlying connection is ready. This will be used for connection
reuse in keep-alive mode.
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 34438d7..f2650d3 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -389,7 +389,7 @@
if (conn->flags & CO_FL_SOCK_WR_SH)
goto out_error;
- if (!(conn->flags & CO_FL_CTRL_READY))
+ if (!conn_ctrl_ready(conn))
goto out_error;
/* If we have a PROXY line to send, we'll use this to validate the
@@ -812,7 +812,7 @@
/* quick close, the socket is alredy shut anyway */
}
else if (si->flags & SI_FL_NOLINGER) {
- if ((conn->flags & CO_FL_CTRL_READY) && conn->ctrl) {
+ if (conn_ctrl_ready(conn)) {
setsockopt(conn->t.sock.fd, SOL_SOCKET, SO_LINGER,
(struct linger *) &nolinger, sizeof(struct linger));
}
@@ -833,7 +833,7 @@
*/
if (!(si->flags & SI_FL_NOHALF) || !(si->ib->flags & (CF_SHUTR|CF_DONT_READ))) {
/* We shutdown transport layer */
- if ((conn->flags & CO_FL_CTRL_READY) && conn->ctrl)
+ if (conn_ctrl_ready(conn))
shutdown(conn->t.sock.fd, SHUT_WR);
if (!(si->ib->flags & (CF_SHUTR|CF_DONT_READ))) {
@@ -931,13 +931,13 @@
/* Before calling the data-level operations, we have to prepare
* the polling flags to ensure we properly detect changes.
*/
- if ((conn->flags & CO_FL_CTRL_READY) && conn->ctrl)
+ if (conn_ctrl_ready(conn))
fd_want_send(conn->t.sock.fd);
conn_refresh_polling_flags(conn);
si_conn_send(conn);
- if ((conn->flags & CO_FL_CTRL_READY) && (conn->flags & CO_FL_ERROR)) {
+ if (conn_ctrl_ready(conn) && (conn->flags & CO_FL_ERROR)) {
/* Write error on the file descriptor */
fd_stop_both(conn->t.sock.fd);
__conn_data_stop_both(conn);
@@ -1287,7 +1287,7 @@
/* we want to immediately forward this close to the write side */
if (si->flags & SI_FL_NOLINGER) {
si->flags &= ~SI_FL_NOLINGER;
- if (conn->flags & CO_FL_CTRL_READY)
+ if (conn_ctrl_ready(conn))
setsockopt(conn->t.sock.fd, SOL_SOCKET, SO_LINGER,
(struct linger *) &nolinger, sizeof(struct linger));
}