Commit 1f4006e8 authored by Dag Haavi Finstad's avatar Dag Haavi Finstad

Merge branch '3.0' of ssh://git.varnish-cache.org/git/varnish-cache into 3.0

parents b50bbd6f b164c06c
...@@ -74,6 +74,8 @@ static struct lock ses_mem_mtx; ...@@ -74,6 +74,8 @@ static struct lock ses_mem_mtx;
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static struct lock stat_mtx; static struct lock stat_mtx;
static volatile uint64_t n_sess_grab = 0;
static uint64_t n_sess_rel = 0;
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
...@@ -214,7 +216,8 @@ SES_New(void) ...@@ -214,7 +216,8 @@ SES_New(void)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
} }
VSC_C_main->n_sess++; /* XXX: locking ? */ /* Only updated from the cache acceptor - no lock needed */
n_sess_grab++;
return (sp); return (sp);
} }
...@@ -255,7 +258,6 @@ SES_Delete(struct sess *sp) ...@@ -255,7 +258,6 @@ SES_Delete(struct sess *sp)
AZ(sp->obj); AZ(sp->obj);
AZ(sp->vcl); AZ(sp->vcl);
VSC_C_main->n_sess--; /* XXX: locking ? */
assert(!isnan(b->first)); assert(!isnan(b->first));
assert(!isnan(sp->t_end)); assert(!isnan(sp->t_end));
if (sp->addr == NULL) if (sp->addr == NULL)
...@@ -267,10 +269,8 @@ SES_Delete(struct sess *sp) ...@@ -267,10 +269,8 @@ SES_Delete(struct sess *sp)
b->sess, b->req, b->pipe, b->pass, b->sess, b->req, b->pipe, b->pass,
b->fetch, b->hdrbytes, b->bodybytes); b->fetch, b->hdrbytes, b->bodybytes);
if (sm->workspace != params->sess_workspace) { if (sm->workspace != params->sess_workspace) {
Lck_Lock(&stat_mtx);
VSC_C_main->n_sess_mem--;
Lck_Unlock(&stat_mtx);
free(sm); free(sm);
sm = NULL;
} else { } else {
/* Clean and prepare for reuse */ /* Clean and prepare for reuse */
ses_setup(sm); ses_setup(sm);
...@@ -279,6 +279,14 @@ SES_Delete(struct sess *sp) ...@@ -279,6 +279,14 @@ SES_Delete(struct sess *sp)
Lck_Unlock(&ses_mem_mtx); Lck_Unlock(&ses_mem_mtx);
} }
/* Update statistics */
Lck_Lock(&stat_mtx);
if (sm == NULL)
VSC_C_main->n_sess_mem--;
n_sess_rel++;
VSC_C_main->n_sess = n_sess_grab - n_sess_rel;
Lck_Unlock(&stat_mtx);
/* Try to precreate some ses-mem so the acceptor will not have to */ /* Try to precreate some ses-mem so the acceptor will not have to */
if (VSC_C_main->n_sess_mem < VSC_C_main->n_sess + 10) { if (VSC_C_main->n_sess_mem < VSC_C_main->n_sess + 10) {
sm = ses_sm_alloc(); sm = ses_sm_alloc();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment