From 91894cbf4c20cd9fdbdd7548596d10b1b0119b91 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Thu, 2 Aug 2018 18:06:28 +0200 Subject: [PATCH] MINOR: stream_interface: Don't use si_cs_send() as a task handler. Instead of using si_cs_send() as a task handler, define a new function, si_cs_io_cb(), and give si_cs_send() its original prototype. Right now si_cs_io_cb() just handles send, but later it'll handle recv() too. --- include/proto/stream_interface.h | 1 + src/stream_interface.c | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index 7fcd4c8ce..a102ac176 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -53,6 +53,7 @@ void stream_int_update(struct stream_interface *si); void stream_int_update_conn(struct stream_interface *si); void stream_int_update_applet(struct stream_interface *si); void stream_int_notify(struct stream_interface *si); +struct task *si_cs_io_cb(struct task *t, void *ctx, unsigned short state); /* returns the channel which receives data from this stream interface (input channel) */ static inline struct channel *si_ic(struct stream_interface *si) diff --git a/src/stream_interface.c b/src/stream_interface.c index 92b8e85c3..290459ab3 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -55,7 +55,7 @@ static void si_cs_recv_cb(struct conn_stream *cs); static int si_cs_wake_cb(struct conn_stream *cs); static int si_idle_conn_wake_cb(struct conn_stream *cs); static void si_idle_conn_null_cb(struct conn_stream *cs); -static struct task * si_cs_send(struct task *t, void *ctx, unsigned short state); +static struct task * si_cs_send(struct conn_stream *cs); /* stream-interface operations for embedded tasks */ struct si_ops si_embedded_ops = { @@ -462,7 +462,7 @@ void stream_int_notify(struct stream_interface *si) /* If we have data to send, try it now */ if (!channel_is_empty(oc) && objt_cs(si->end)) - si_cs_send(NULL, objt_cs(si->end), 0); + si_cs_send(objt_cs(si->end)); /* process consumer side */ if (channel_is_empty(oc)) { @@ -642,9 +642,8 @@ static int si_cs_wake_cb(struct conn_stream *cs) * caller to commit polling changes. The caller should check conn->flags * for errors. */ -static struct task * si_cs_send(struct task *t, void *ctx, unsigned short state) +static struct task * si_cs_send(struct conn_stream *cs) { - struct conn_stream *cs = ctx; struct connection *conn = cs->conn; struct stream_interface *si = cs->data; struct channel *oc = si_oc(si); @@ -661,7 +660,7 @@ static struct task * si_cs_send(struct task *t, void *ctx, unsigned short state) if (conn->flags & CO_FL_HANDSHAKE) { /* a handshake was requested */ /* Schedule ourself to be woken up once the handshake is done */ - conn->xprt->subscribe(conn, SUB_CAN_SEND, wl_set_waitcb(&cs->wait_list, si_cs_send, ctx)); + conn->xprt->subscribe(conn, SUB_CAN_SEND, wl_set_waitcb(&cs->wait_list, si_cs_io_cb, cs)); return NULL; } @@ -741,7 +740,7 @@ static struct task * si_cs_send(struct task *t, void *ctx, unsigned short state) } /* We couldn't send all of our data, let the mux know we'd like to send more */ if (co_data(oc)) - conn->mux->subscribe(cs, SUB_CAN_SEND, wl_set_waitcb(&cs->wait_list, si_cs_send, ctx)); + conn->mux->subscribe(cs, SUB_CAN_SEND, wl_set_waitcb(&cs->wait_list, si_cs_io_cb, cs)); wake_others: /* Maybe somebody was waiting for this conn_stream, wake them */ @@ -758,6 +757,12 @@ wake_others: return NULL; } +struct task *si_cs_io_cb(struct task *t, void *ctx, unsigned short state) +{ + si_cs_send(ctx); + return (NULL); +} + /* This function is designed to be called from within the stream handler to * update the channels' expiration timers and the stream interface's flags * based on the channels' flags. It needs to be called only once after the @@ -1045,7 +1050,7 @@ static void stream_int_chk_snd_conn(struct stream_interface *si) __cs_want_send(cs); - si_cs_send(NULL, cs, 0); + si_cs_send(cs); if (cs->flags & CS_FL_ERROR || cs->conn->flags & CO_FL_ERROR) { /* Write error on the file descriptor */ __cs_stop_both(cs);