Commit 11d8d518 authored by Geoff Simmons's avatar Geoff Simmons

Added parameter unique_xids -- use a mutex to ensure unique XIDs

Signed-off-by: Geoff Simmons's avatarGeoff Simmons <geoff@uplex.de>
parent 9e6a70f0
......@@ -77,6 +77,7 @@ DOT acceptor -> start [style=bold,color=green]
#include "vsha256.h"
static unsigned xids;
static struct lock xids_mtx;
/*--------------------------------------------------------------------
* WAIT
......@@ -1478,7 +1479,13 @@ cnt_start(struct sess *sp)
sp->wrk->acct_tmp.req++;
/* Assign XID and log */
sp->xid = ++xids; /* XXX not locked */
if (params->unique_xids) {
Lck_Lock(&xids_mtx);
sp->xid = ++xids;
Lck_Unlock(&xids_mtx);
}
else
sp->xid = ++xids;
WSP(sp, SLT_ReqStart, "%s %s %u", sp->addr, sp->port, sp->xid);
/* Borrow VCL reference from worker thread */
......@@ -1696,6 +1703,8 @@ CNT_Init(void)
srandomdev();
srand48(random());
xids = random();
if (params->unique_xids)
Lck_New(&xids_mtx, lck_xids);
CLI_AddFuncs(debug_cmds);
}
......
......@@ -214,6 +214,8 @@ struct params {
double shortlived;
struct vre_limits vre_limits;
unsigned unique_xids;
};
/*
......
......@@ -49,4 +49,5 @@ LOCK(ban)
LOCK(vbp)
LOCK(vbe)
LOCK(backend)
LOCK(xids)
/*lint -restore */
......@@ -974,6 +974,12 @@ static const struct parspec input_parspec[] = {
0,
"10000", ""},
{ "unique_xids", tweak_bool, &master.unique_xids, 0, 0,
"Ensure that XIDs are uniquely assigned to requests "
"using an additional mutex.\n",
0,
"off", "bool" },
{ NULL, NULL, NULL }
};
......
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