MEDIUM: stream: make stream_new() allocate its own task
Currently a task is allocated in session_new() and serves two purposes :
- either the handshake is complete and it is offered to the stream via
the second arg of stream_new()
- or the handshake is not complete and it's diverted to be used as a
timeout handler for the embryonic session and repurposed once we land
into conn_complete_session()
Furthermore, the task's process() function was taken from the listener's
handler in conn_complete_session() prior to being replaced by a call to
stream_new(). This will become a serious mess with the mux.
Since it's impossible to have a stream without a task, this patch removes
the second arg from stream_new() and make this function allocate its own
task. In session_accept_fd(), we now only allocate the task if needed for
the embryonic session and delete it later.
diff --git a/src/flt_spoe.c b/src/flt_spoe.c
index 1a8bd2c..47aef57 100644
--- a/src/flt_spoe.c
+++ b/src/flt_spoe.c
@@ -1901,7 +1901,6 @@
{
struct appctx *appctx;
struct session *sess;
- struct task *task;
struct stream *strm;
if ((appctx = appctx_new(&spoe_applet)) == NULL)
@@ -1937,12 +1936,9 @@
if (!sess)
goto out_free_spoe;
- if ((task = task_new()) == NULL)
+ if ((strm = stream_new(sess, &appctx->obj_type)) == NULL)
goto out_free_sess;
- if ((strm = stream_new(sess, task, &appctx->obj_type)) == NULL)
- goto out_free_task;
-
stream_set_backend(strm, conf->agent->b.be);
/* applet is waiting for data */
@@ -1960,12 +1956,10 @@
LIST_ADDQ(&conf->agent->applets, &SPOE_APPCTX(appctx)->list);
conf->agent->applets_act++;
- task_wakeup(task, TASK_WOKEN_INIT);
+ task_wakeup(strm->task, TASK_WOKEN_INIT);
return appctx;
/* Error unrolling */
- out_free_task:
- task_free(task);
out_free_sess:
session_free(sess);
out_free_spoe: