MEDIUM: session: take care of incrementing/decrementing jobs
Each user of a session increments/decrements the jobs variable at its
own place, resulting in a real mess and inconsistencies between them.
Let's have session_new() increment jobs and session_free() decrement
it.
diff --git a/src/flt_spoe.c b/src/flt_spoe.c
index 47aef57..f278809 100644
--- a/src/flt_spoe.c
+++ b/src/flt_spoe.c
@@ -1949,7 +1949,6 @@
strm->res.flags |= CF_READ_DONTWAIT;
conf->agent_fe.feconn++;
- jobs++;
totalconn++;
task_wakeup(SPOE_APPCTX(appctx)->task, TASK_WOKEN_INIT);
diff --git a/src/hlua.c b/src/hlua.c
index acf5896..e1b7264 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -2415,7 +2415,6 @@
/* Update statistics counters. */
socket_proxy.feconn++; /* beconn will be increased later */
- jobs++;
totalconn++;
task_wakeup(strm->task, TASK_WOKEN_INIT);
diff --git a/src/listener.c b/src/listener.c
index d193b51..0af49b0 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -527,7 +527,6 @@
actconn++;
}
- jobs++;
totalconn++;
l->nbconn++;
@@ -545,7 +544,6 @@
*/
if (!(l->options & LI_O_UNLIMITED))
actconn--;
- jobs--;
l->nbconn--;
if (ret == 0) /* successful termination */
continue;
diff --git a/src/peers.c b/src/peers.c
index 8fb3b78..17f1867 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1836,7 +1836,6 @@
s->res.flags |= CF_READ_DONTWAIT;
p->feconn++;/* beconn will be increased later */
- jobs++;
totalconn++;
peer->appctx = appctx;
diff --git a/src/session.c b/src/session.c
index c86baff..68a4303 100644
--- a/src/session.c
+++ b/src/session.c
@@ -53,6 +53,7 @@
memset(sess->stkctr, 0, sizeof(sess->stkctr));
vars_init(&sess->vars, SCOPE_SESS);
sess->task = NULL;
+ jobs++;
}
return sess;
}
@@ -64,6 +65,7 @@
session_store_counters(sess);
vars_prune_per_sess(&sess->vars);
pool_free2(pool2_session, sess);
+ jobs--;
}
/* perform minimal intializations, report 0 in case of error, 1 if OK. */
@@ -377,7 +379,6 @@
if (!(sess->listener->options & LI_O_UNLIMITED))
actconn--;
- jobs--;
sess->listener->nbconn--;
if (sess->listener->state == LI_FULL)
resume_listener(sess->listener);
diff --git a/src/stream.c b/src/stream.c
index e9d6400..d8c1a7e 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -2420,7 +2420,7 @@
sess->fe->feconn--;
if (s->flags & SF_BE_ASSIGNED)
s->be->beconn--;
- jobs--;
+
if (sess->listener) {
if (!(sess->listener->options & LI_O_UNLIMITED))
actconn--;