From 45ca9dadcd02d8473a2cfdc7d6e4fc7e1200238f Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 10 Jan 2024 14:23:38 +0100 Subject: [PATCH] MINOR: stconn: Be prepared to handle error when a SC is attached to an applet sc_attach_applet() was changed to be able to fail and callers were updated accordingly. For now it cannot fail but if this changes, callers will be prepared to handle errors. --- src/stconn.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/stconn.c b/src/stconn.c index a5ab35127..c6d61a40d 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -312,7 +312,7 @@ int sc_attach_mux(struct stconn *sc, void *sd, void *ctx) * removed. This function is called by a stream when a backend applet is * registered. */ -static void sc_attach_applet(struct stconn *sc, struct appctx *appctx) +static int sc_attach_applet(struct stconn *sc, struct appctx *appctx) { sc->sedesc->se = appctx; sc_ep_set(sc, SE_FL_T_APPLET); @@ -321,6 +321,8 @@ static void sc_attach_applet(struct stconn *sc, struct appctx *appctx) sc->app_ops = &sc_app_applet_ops; xref_create(&sc->sedesc->xref, &sc_opposite(sc)->sedesc->xref); } + + return 0; } /* Attaches a stconn to a app layer and sets the relevant @@ -506,7 +508,10 @@ struct appctx *sc_applet_create(struct stconn *sc, struct applet *app) appctx = appctx_new_here(app, sc->sedesc); if (!appctx) return NULL; - sc_attach_applet(sc, appctx); + if (sc_attach_applet(sc, appctx) == -1) { + appctx_free_on_early_error(appctx); + return NULL; + } appctx->t->nice = __sc_strm(sc)->task->nice; applet_need_more_data(appctx); appctx_wakeup(appctx);