From c07a9d0aee10d37d55c8a6f60cf261da9e2d44cd Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 6 May 2010 00:55:03 +0100 Subject: [PATCH] lowvol fixes --- backends/innduct.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/backends/innduct.c b/backends/innduct.c index c42771d..6e9dd26 100644 --- a/backends/innduct.c +++ b/backends/innduct.c @@ -533,7 +533,7 @@ static char *globpat_backlog; static pid_t self_pid; static int *lowvol_perperiod; static int lowvol_circptr; -static int lowvol_total; +static int lowvol_total; /* does not include current period */ /* statemc_init initialises */ static StateMachineState sms; @@ -1191,9 +1191,10 @@ static void conn_idle_close(Conn *conn, const char *why) { static void check_idle_conns(void) { Conn *conn; - int verylowvol= lowvol_perperiod[lowvol_circptr]; + int volthisperiod= lowvol_perperiod[lowvol_circptr]; lowvol_circptr++; lowvol_circptr %= lowvol_periods; + lowvol_total += volthisperiod; lowvol_total -= lowvol_perperiod[lowvol_circptr]; lowvol_perperiod[lowvol_circptr]= 0; @@ -1222,9 +1223,9 @@ static void check_idle_conns(void) { } conn= LIST_HEAD(conns); - if (!verylowvol && + if (!volthisperiod && conns.count==1 && - lowvol_total+verylowvol < lowvol_thresh && + lowvol_total < lowvol_thresh && !conn_busy(conn)) conn_idle_close(conn, "low volume"); } @@ -3406,7 +3407,7 @@ CCMD(dump) { DUMPV("%d", , cli_master); fprintf(f,"\n"); - fprintf(f,"lowvol "); + fprintf(f,"lowvol"); DUMPV("%d", , lowvol_circptr); DUMPV("%d", , lowvol_total); fprintf(f,":"); @@ -3785,6 +3786,7 @@ int main(int argc, char **argv) { lowvol_perperiod[i]= lowvol_thresh; lowvol_total += lowvol_thresh; } + lowvol_total -= lowvol_thresh; /* set things up */ -- 2.30.2