From e34070e1be8f7ae7c70f3c00f904bef6ad755aad Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 8 Jan 2010 00:32:27 +0100 Subject: [PATCH] [MEDIUM] session: limit the number of analyser loops The initial code's intention was to loop on the analysers as long as an analyser is added by another one. [This code was wrong due to the while(0) which breaks even on a continue statement, but the initial intention must be changed too]. In fact we should limit the number of times we loop on analysers in order to limit latency. Using maxpollevents as a limit makes sense since this tunable is used for the exact same purposes. We may add another tunable later if that ever makes sense, so it's very unlikely. --- src/session.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/session.c b/src/session.c index 48c8ce9c9..5e8c990ab 100644 --- a/src/session.c +++ b/src/session.c @@ -790,6 +790,7 @@ struct task *process_session(struct task *t) unsigned int flags = s->req->flags; if (s->req->prod->state >= SI_ST_EST) { + int max_loops = global.tune.maxpollevents; unsigned int ana_list; unsigned int ana_back; @@ -838,10 +839,7 @@ struct task *process_session(struct task *t) */ ana_list = ana_back = s->req->analysers; - do { - if (!ana_list) - break; - + while (ana_list && max_loops--) { /* Warning! ensure that analysers are always placed in ascending order! */ if (ana_list & AN_REQ_INSPECT) { @@ -903,7 +901,8 @@ struct task *process_session(struct task *t) break; UPDATE_ANALYSERS(s->req->analysers, ana_list, ana_back, AN_REQ_HTTP_XFER_BODY); } - } while (0); + break; + } } if ((s->req->flags ^ flags) & BF_MASK_STATIC) { @@ -942,6 +941,7 @@ struct task *process_session(struct task *t) unsigned int flags = s->rep->flags; if (s->rep->prod->state >= SI_ST_EST) { + int max_loops = global.tune.maxpollevents; unsigned int ana_list; unsigned int ana_back; @@ -966,7 +966,7 @@ struct task *process_session(struct task *t) */ ana_list = ana_back = s->rep->analysers; - do { + while (ana_list && max_loops--) { if (!ana_list) break; @@ -989,7 +989,8 @@ struct task *process_session(struct task *t) break; UPDATE_ANALYSERS(s->rep->analysers, ana_list, ana_back, AN_RES_HTTP_XFER_BODY); } - } while (0); + break; + } } if ((s->rep->flags ^ flags) & BF_MASK_STATIC) {