diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index 6380f7614..ed8725710 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -164,7 +164,7 @@ static inline void si_release_endpoint(struct stream_interface *si) conn_free(conn); } else if ((appctx = objt_appctx(si->end))) { - if (appctx->applet->release) + if (appctx->applet->release && si->state < SI_ST_DIS) appctx->applet->release(appctx); appctx_free(appctx); /* we share the connection pool */ } @@ -231,7 +231,7 @@ static inline void si_applet_release(struct stream_interface *si) struct appctx *appctx; appctx = si_appctx(si); - if (appctx && appctx->applet->release) + if (appctx && appctx->applet->release && si->state < SI_ST_DIS) appctx->applet->release(appctx); } diff --git a/src/stream_interface.c b/src/stream_interface.c index 2341720b3..d39d7647e 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -1406,9 +1406,9 @@ static void stream_int_shutr_applet(struct stream_interface *si) return; if (si_oc(si)->flags & CF_SHUTW) { + si_applet_release(si); si->state = SI_ST_DIS; si->exp = TICK_ETERNITY; - si_applet_release(si); } else if (si->flags & SI_FL_NOHALF) { /* we want to immediately forward this close to the write side */ @@ -1456,8 +1456,8 @@ static void stream_int_shutw_applet(struct stream_interface *si) case SI_ST_QUE: case SI_ST_TAR: /* Note that none of these states may happen with applets */ - si->state = SI_ST_DIS; si_applet_release(si); + si->state = SI_ST_DIS; default: si->flags &= ~(SI_FL_WAIT_ROOM | SI_FL_NOLINGER); ic->flags &= ~CF_SHUTR_NOW;