Commit 90846c4a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Remove sp->req, sessions can now (almost) have more than one request

at a time, paving the way for a lot of future fun...

It's painfully obvious that I set about doing this the wrong way:
I should have renamed sess to req and made a new sess structure,
that would have been much simpler.
parent 5894995f
......@@ -660,7 +660,6 @@ struct sess {
/* Cross references ------------------------------------------*/
struct sesspool *sesspool;
struct req *req;
struct pool_task task;
VTAILQ_ENTRY(sess) list;
......@@ -866,8 +865,6 @@ void THR_SetName(const char *name);
const char* THR_GetName(void);
void THR_SetRequest(const struct req *);
const struct req * THR_GetRequest(void);
void THR_SetSession(const struct sess *);
const struct sess * THR_GetSession(void);
/* cache_lck.c */
......@@ -930,7 +927,6 @@ struct sesspool *SES_NewPool(struct pool *pp, unsigned pool_no);
void SES_DeletePool(struct sesspool *sp);
int SES_ScheduleReq(struct req *);
void SES_Handle(struct sess *sp, double now);
struct req *SES_GetReq(struct sess *sp);
void SES_ReleaseReq(struct req *);
pool_func_t SES_pool_accept_task;
......
......@@ -334,7 +334,6 @@ CNT_Session(struct worker *wrk, struct req *req)
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
sp = req->sp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
assert(sp->req == req);
/*
* Whenever we come in from the acceptor or waiter, we need to set
......@@ -358,7 +357,6 @@ CNT_Session(struct worker *wrk, struct req *req)
/*
* Possible entrance states
*/
assert(sp->req == req);
assert(
sp->sess_step == S_STP_NEWREQ ||
......
......@@ -48,20 +48,6 @@ volatile struct params *cache_param;
static pthread_key_t sp_key;
static pthread_key_t req_key;
void
THR_SetSession(const struct sess *sp)
{
AZ(pthread_setspecific(sp_key, sp));
}
const struct sess *
THR_GetSession(void)
{
return (pthread_getspecific(sp_key));
}
void
THR_SetRequest(const struct req *req)
{
......
......@@ -57,6 +57,8 @@
static struct vsb pan_vsp_storage, *pan_vsp;
static pthread_mutex_t panicstr_mtx = PTHREAD_MUTEX_INITIALIZER;
static void pan_sess(const struct sess *sp);
/*--------------------------------------------------------------------*/
static void
......@@ -261,6 +263,9 @@ pan_req(const struct req *req)
VSB_printf(pan_vsp, " restarts = %d, esi_level = %d\n",
req->restarts, req->esi_level);
if (req->sp != NULL)
pan_sess(req->sp);
if (req->wrk != NULL)
pan_wrk(req->wrk);
......@@ -343,7 +348,6 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
int err, int xxx)
{
const char *q;
const struct sess *sp;
const struct req *req;
AZ(pthread_mutex_lock(&panicstr_mtx)); /* Won't be released,
......@@ -385,9 +389,6 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
pan_backtrace();
if (!(cache_param->diag_bitmap & 0x2000)) {
sp = THR_GetSession();
if (sp != NULL)
pan_sess(sp);
req = THR_GetRequest();
if (req != NULL)
pan_req(req);
......
......@@ -46,6 +46,8 @@
static unsigned ses_size = sizeof (struct sess);
static struct req * ses_GetReq(struct sess *sp);
/*--------------------------------------------------------------------*/
struct sesspool {
......@@ -134,9 +136,7 @@ ses_pool_task(struct worker *wrk, void *arg)
AZ(wrk->aws->r);
wrk->lastused = NAN;
THR_SetSession(sp);
CNT_Session(wrk, req);
THR_SetSession(NULL);
WS_Assert(wrk->aws);
AZ(wrk->wrw);
if (cache_param->diag_bitmap & 0x00040000) {
......@@ -168,7 +168,7 @@ SES_pool_accept_task(struct worker *wrk, void *arg)
}
VCA_SetupSess(wrk, sp);
sp->sess_step = S_STP_NEWREQ;
req = SES_GetReq(sp);
req = ses_GetReq(sp);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
ses_pool_task(wrk, req);
}
......@@ -218,8 +218,7 @@ SES_Handle(struct sess *sp, double now)
pp = sp->sesspool;
CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC);
AN(pp->pool);
AZ(sp->req);
req = SES_GetReq(sp);
req = ses_GetReq(sp);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
sp->task.func = ses_pool_task;
sp->task.priv = req;
......@@ -266,7 +265,6 @@ SES_Delete(struct sess *sp, const char *reason, double now)
struct sesspool *pp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AZ(sp->req);
pp = sp->sesspool;
CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC);
AN(pp->pool);
......@@ -296,11 +294,11 @@ SES_Delete(struct sess *sp, const char *reason, double now)
}
/*--------------------------------------------------------------------
* Alloc/Free sp->req
* Alloc/Free a request
*/
struct req *
SES_GetReq(struct sess *sp)
static struct req *
ses_GetReq(struct sess *sp)
{
struct sesspool *pp;
struct req *req;
......@@ -313,11 +311,9 @@ SES_GetReq(struct sess *sp)
CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC);
AN(pp->pool);
AZ(sp->req);
req = MPL_Get(pp->mpl_req, &sz);
AN(req);
req->magic = REQ_MAGIC;
sp->req = req;
req->sp = sp;
THR_SetRequest(req);
......@@ -370,7 +366,6 @@ SES_ReleaseReq(struct req *req)
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
sp = req->sp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
assert(sp->req == req);
pp = sp->sesspool;
CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC);
AN(pp->pool);
......@@ -379,7 +374,6 @@ SES_ReleaseReq(struct req *req)
VSL_Flush(req->vsl, 0);
req->sp = NULL;
MPL_Free(pp->mpl_req, req);
sp->req = NULL;
THR_SetRequest(NULL);
}
......
......@@ -67,7 +67,6 @@ WAIT_Enter(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AZ(sp->req);
assert(sp->fd >= 0);
/*
......
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