Commit 6aa2e499 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Shift the responsibility for washing used sessions.

Instead of the acceptor thread doing it when reusing the session, have the
worker threads clean it out before putting it on the free list.

It could be, and probably was, argued that this is a performance
pessimization, but having thought much about it, I can't spot the
argument any longer, and certainly moving load off the acceptor thread
to the massively parallel worker threads is a good idea.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4071 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 5c0fe1fa
......@@ -108,13 +108,17 @@ sock_test(int fd)
need_test = 0;
}
/*--------------------------------------------------------------------
* Called once the workerthread gets hold of the session, to do setup
* setup overhead, we don't want to bother the acceptor thread with.
*/
void
VCA_Prep(struct sess *sp)
{
char addr[TCP_ADDRBUFSIZE];
char port[TCP_PORTBUFSIZE];
TCP_name(sp->sockaddr, sp->sockaddrlen,
addr, sizeof addr, port, sizeof port);
sp->addr = WS_Dup(sp->ws, addr);
......
......@@ -122,6 +122,8 @@ ses_setup(struct sessmem *sm, const struct sockaddr *addr, unsigned len)
sm = malloc(sizeof *sm + u);
if (sm == NULL)
return (NULL);
/* Don't waste time zeroing the workspace */
memset(sm, 0, sizeof *sm);
sm->magic = SESSMEM_MAGIC;
sm->workspace = u;
VSL_stats->n_sess_mem++;
......@@ -129,7 +131,6 @@ ses_setup(struct sessmem *sm, const struct sockaddr *addr, unsigned len)
CHECK_OBJ_NOTNULL(sm, SESSMEM_MAGIC);
VSL_stats->n_sess++;
sp = &sm->sess;
memset(sp, 0, sizeof *sp);
sp->magic = SESS_MAGIC;
sp->mem = sm;
sp->sockaddr = (void*)(&sm->sockaddr[0]);
......@@ -201,6 +202,7 @@ SES_Delete(struct sess *sp)
{
struct acct *b = &sp->acct;
struct sessmem *sm;
unsigned workspace;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
sm = sp->mem;
......@@ -219,6 +221,12 @@ SES_Delete(struct sess *sp)
VSL_stats->n_sess_mem--;
free(sm);
} else {
/* Clean and prepare for reuse */
workspace = sm->workspace;
memset(sm, 0, sizeof *sm);
sm->magic = SESSMEM_MAGIC;
sm->workspace = workspace;
Lck_Lock(&ses_mem_mtx);
VTAILQ_INSERT_HEAD(&ses_free_mem[1 - ses_qp], sm, list);
Lck_Unlock(&ses_mem_mtx);
......
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