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