diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index 17222c524..22c68fbd9 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -132,6 +132,14 @@ static inline void __appctx_free(struct appctx *appctx) _HA_ATOMIC_DEC(&nb_applets); } +static inline void appctx_shutw(struct appctx *appctx) +{ + if (se_fl_test(appctx->sedesc, SE_FL_SHW)) + return; + + se_fl_set(appctx->sedesc, SE_FL_SHWN); +} + /* wakes up an applet when conditions have changed. We're using a macro here in * order to retrieve the caller's place. */ diff --git a/src/applet.c b/src/applet.c index 275e4e65c..4fc4e4018 100644 --- a/src/applet.c +++ b/src/applet.c @@ -395,7 +395,7 @@ void applet_reset_svcctx(struct appctx *appctx) */ void appctx_shut(struct appctx *appctx) { - if (se_fl_test(appctx->sedesc, SE_FL_SHR | SE_FL_SHW)) + if (applet_fl_test(appctx, APPCTX_FL_SHUTDOWN)) return; TRACE_ENTER(APPLET_EV_RELEASE, appctx); diff --git a/src/stconn.c b/src/stconn.c index 70f27db81..9951c80f4 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -917,6 +917,8 @@ static void sc_app_shut_applet(struct stconn *sc) switch (sc->state) { case SC_ST_RDY: case SC_ST_EST: + appctx_shutw(__sc_appctx(sc)); + /* we have to shut before closing, otherwise some short messages * may never leave the system, especially when there are remaining * unread data in the socket input buffer, or when nolinger is set.