From: Willy Tarreau Date: Sun, 19 Apr 2015 23:31:23 +0000 (+0200) Subject: MEDIUM: applet: centralize the call to si_applet_done() in the I/O handler X-Git-Tag: v1.6-dev2~188 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4da196546a78a11953aa6b48b3bb7fece7a0983;p=thirdparty%2Fhaproxy.git MEDIUM: applet: centralize the call to si_applet_done() in the I/O handler It's much easier to centralize this call into the I/O handler than to do it everywhere with the risk to miss it. Applets are not allowed to unregister themselves anyway so their SI is still present and it is possible to update all the context. --- diff --git a/src/applet.c b/src/applet.c index 3aa67e72c0..37303f7447 100644 --- a/src/applet.c +++ b/src/applet.c @@ -38,6 +38,6 @@ void applet_run_active() } curr->applet->fct(curr); - /* must not dereference curr nor si now because it might have been freed */ + si_applet_done(si); } } diff --git a/src/dumpstats.c b/src/dumpstats.c index 5a890e9dd0..c835b1eb98 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -2429,13 +2429,6 @@ static void cli_io_handler(struct appctx *appctx) } out: - /* update all other flags and resync with the other side */ - si_applet_done(si); - - /* we don't want to expire timeouts while we're processing requests */ - si_ic(si)->rex = TICK_ETERNITY; - si_oc(si)->wex = TICK_ETERNITY; - DPRINTF(stderr, "%s@%d: st=%d, rqf=%x, rpf=%x, rqh=%d, rqs=%d, rh=%d, rs=%d\n", __FUNCTION__, __LINE__, si->state, req->flags, res->flags, req->buf->i, req->buf->o, res->buf->i, res->buf->o); @@ -4961,14 +4954,8 @@ static void http_stats_io_handler(struct appctx *appctx) res->flags |= CF_READ_NULL; } } - out: - /* update all other flags and resync with the other side */ - si_applet_done(si); - - /* we don't want to expire timeouts while we're processing requests */ - si_ic(si)->rex = TICK_ETERNITY; - si_oc(si)->wex = TICK_ETERNITY; + /* just to make gcc happy */ ; } diff --git a/src/hlua.c b/src/hlua.c index fb006e6e1e..37fce89edf 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -1446,11 +1446,11 @@ static void hlua_socket_handler(struct appctx *appctx) si_ic(si)->flags |= CF_READ_NULL; hlua_com_wake(&appctx->ctx.hlua.wake_on_read); hlua_com_wake(&appctx->ctx.hlua.wake_on_write); - goto leave; + return; } if (!(c->flags & CO_FL_CONNECTED)) - goto leave; + return; /* This function is called after the connect. */ appctx->ctx.hlua.connected = 1; @@ -1462,9 +1462,6 @@ static void hlua_socket_handler(struct appctx *appctx) /* Wake the tasks which wants to read if the buffer contains data. */ if (channel_is_empty(si_ic(si))) hlua_com_wake(&appctx->ctx.hlua.wake_on_read); - - leave: - si_applet_done(si); } /* This function is called when the "struct stream" is destroyed. diff --git a/src/peers.c b/src/peers.c index 97a87289da..5b6d817861 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1043,11 +1043,7 @@ incomplete: } } out: - si_applet_done(si); si_oc(si)->flags |= CF_READ_DONTWAIT; - /* we don't want to expire timeouts while we're processing requests */ - si_ic(si)->rex = TICK_ETERNITY; - si_oc(si)->wex = TICK_ETERNITY; return; full: si->flags |= SI_FL_WAIT_ROOM;