MINOR: connection: provide a generic data layer wakeup callback
Instead of calling conn_notify_si() from the connection handler, we
now call data->wake(), which will allow us to use a different callback
with health checks.
Note that we still rely on a flag in order to decide whether or not
to call this function. The reason is that with embryonic sessions,
the callback is already initialized to si_conn_cb without the flag,
and we can't call the SI notify function in the leave path before
the stream interface is initialized.
This issue should be addressed by involving a different data_cb for
embryonic sessions and for stream interfaces, that would be changed
during session_complete() for the final data_cb.
diff --git a/src/connection.c b/src/connection.c
index 07225e9..007d3b1 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -110,8 +110,8 @@
return 0;
}
- if (conn->flags & CO_FL_NOTIFY_SI)
- conn_notify_si(conn);
+ if (conn->flags & CO_FL_WAKE_DATA)
+ conn->data->wake(conn);
/* Last check, verify if the connection just established */
if (unlikely(!(conn->flags & (CO_FL_WAIT_L4_CONN | CO_FL_WAIT_L6_CONN | CO_FL_CONNECTED))))
diff --git a/src/session.c b/src/session.c
index 975176c..b697599 100644
--- a/src/session.c
+++ b/src/session.c
@@ -462,7 +462,7 @@
}
/* we want the connection handler to notify the stream interface about updates. */
- s->si[0].conn.flags |= CO_FL_NOTIFY_SI;
+ s->si[0].conn.flags |= CO_FL_WAKE_DATA;
/* it is important not to call the wakeup function directly but to
* pass through task_wakeup(), because this one knows how to apply
diff --git a/src/stream_interface.c b/src/stream_interface.c
index faeddde..83e0859 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -44,6 +44,9 @@
static void stream_int_update_conn(struct stream_interface *si);
static void stream_int_chk_rcv_conn(struct stream_interface *si);
static void stream_int_chk_snd_conn(struct stream_interface *si);
+static void si_conn_recv_cb(struct connection *conn);
+static void si_conn_send_cb(struct connection *conn);
+static void si_conn_wake_cb(struct connection *conn);
/* stream-interface operations for embedded tasks */
struct si_ops si_embedded_ops = {
@@ -69,6 +72,7 @@
struct data_cb si_conn_cb = {
.recv = si_conn_recv_cb,
.send = si_conn_send_cb,
+ .wake = si_conn_wake_cb,
};
/*
@@ -554,12 +558,12 @@
}
/* Callback to be used by connection I/O handlers upon completion. It differs from
- * the function below in that it is designed to be called by lower layers after I/O
+ * the update function in that it is designed to be called by lower layers after I/O
* events have been completed. It will also try to wake the associated task up if
* an important event requires special handling. It relies on the connection handler
* to commit any polling updates.
*/
-void conn_notify_si(struct connection *conn)
+static void si_conn_wake_cb(struct connection *conn)
{
struct stream_interface *si = conn->owner;
@@ -938,7 +942,7 @@
* into the buffer from the connection. It iterates over the transport layer's
* rcv_buf function.
*/
-void si_conn_recv_cb(struct connection *conn)
+static void si_conn_recv_cb(struct connection *conn)
{
struct stream_interface *si = conn->owner;
struct channel *b = si->ib;
@@ -1152,7 +1156,7 @@
* from the buffer to the connection. It iterates over the transport layer's
* snd_buf function.
*/
-void si_conn_send_cb(struct connection *conn)
+static void si_conn_send_cb(struct connection *conn)
{
struct stream_interface *si = conn->owner;
struct channel *b = si->ob;