Commit 4c4d6f65 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make sure that all sessions, requests and busyobj's have a

unique transaction id 'vxid'
parent 27d63c26
...@@ -259,7 +259,7 @@ struct vsl_log { ...@@ -259,7 +259,7 @@ struct vsl_log {
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
struct vxid { struct vxid_pool {
uint32_t next; uint32_t next;
uint32_t count; uint32_t count;
}; };
...@@ -275,7 +275,6 @@ struct wrk_accept { ...@@ -275,7 +275,6 @@ struct wrk_accept {
socklen_t acceptaddrlen; socklen_t acceptaddrlen;
int acceptsock; int acceptsock;
struct listen_sock *acceptlsock; struct listen_sock *acceptlsock;
uint32_t vxid;
}; };
/* Worker pool stuff -------------------------------------------------*/ /* Worker pool stuff -------------------------------------------------*/
...@@ -319,6 +318,7 @@ struct worker { ...@@ -319,6 +318,7 @@ struct worker {
struct ws aws[1]; struct ws aws[1];
struct vxid_pool vxid_pool;
/* Temporary accounting */ /* Temporary accounting */
struct acct acct_tmp; struct acct acct_tmp;
...@@ -472,6 +472,7 @@ struct busyobj { ...@@ -472,6 +472,7 @@ struct busyobj {
* is recycled. * is recycled.
*/ */
unsigned refcount; unsigned refcount;
uint32_t vxid;
uint8_t *vary; uint8_t *vary;
unsigned is_gzip; unsigned is_gzip;
...@@ -560,6 +561,7 @@ struct req { ...@@ -560,6 +561,7 @@ struct req {
unsigned magic; unsigned magic;
#define REQ_MAGIC 0x2751aaa1 #define REQ_MAGIC 0x2751aaa1
uint32_t vxid;
unsigned xid; unsigned xid;
int restarts; int restarts;
int esi_level; int esi_level;
...@@ -655,7 +657,6 @@ struct sess { ...@@ -655,7 +657,6 @@ struct sess {
int fd; int fd;
unsigned vsl_id; unsigned vsl_id;
uint32_t vxid; uint32_t vxid;
uint32_t vseq;
/* Cross references ------------------------------------------*/ /* Cross references ------------------------------------------*/
...@@ -857,7 +858,7 @@ int HTC_Complete(struct http_conn *htc); ...@@ -857,7 +858,7 @@ int HTC_Complete(struct http_conn *htc);
#undef HTTPH #undef HTTPH
/* cache_main.c */ /* cache_main.c */
uint32_t VXID_Get(struct vxid *v); uint32_t VXID_Get(struct vxid_pool *v);
extern volatile struct params * cache_param; extern volatile struct params * cache_param;
void THR_SetName(const char *name); void THR_SetName(const char *name);
const char* THR_GetName(void); const char* THR_GetName(void);
......
...@@ -248,8 +248,6 @@ VCA_SetupSess(struct worker *wrk, struct sess *sp) ...@@ -248,8 +248,6 @@ VCA_SetupSess(struct worker *wrk, struct sess *sp)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC); CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC);
sp->vxid = wa->vxid;
sp->vseq = 0;
sp->fd = wa->acceptsock; sp->fd = wa->acceptsock;
sp->vsl_id = wa->acceptsock | VSL_CLIENTMARKER ; sp->vsl_id = wa->acceptsock | VSL_CLIENTMARKER ;
wa->acceptsock = -1; wa->acceptsock = -1;
......
...@@ -108,6 +108,7 @@ VBO_GetBusyObj(struct worker *wrk) ...@@ -108,6 +108,7 @@ VBO_GetBusyObj(struct worker *wrk)
AZ(bo->refcount); AZ(bo->refcount);
bo->refcount = 1; bo->refcount = 1;
bo->vxid = VXID_Get(&wrk->vxid_pool);
p = (void*)(bo + 1); p = (void*)(bo + 1);
p = (void*)PRNDUP(p); p = (void*)PRNDUP(p);
......
...@@ -277,6 +277,7 @@ cnt_sess_done(struct sess *sp, struct worker *wrk, struct req *req) ...@@ -277,6 +277,7 @@ cnt_sess_done(struct sess *sp, struct worker *wrk, struct req *req)
WS_Reset(req->ws, NULL); WS_Reset(req->ws, NULL);
WS_Reset(wrk->aws, NULL); WS_Reset(wrk->aws, NULL);
req->vxid = VXID_Get(&wrk->vxid_pool);
i = HTC_Reinit(req->htc); i = HTC_Reinit(req->htc);
if (i == 1) { if (i == 1) {
......
...@@ -85,13 +85,15 @@ THR_GetName(void) ...@@ -85,13 +85,15 @@ THR_GetName(void)
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
* VXID's are unique transaction numbers allocated with a minimum of
* locking overhead via pools in the worker threads.
*/ */
static uint32_t vxid_base; static uint32_t vxid_base;
static struct lock vxid_lock; static struct lock vxid_lock;
static void static void
vxid_More(struct vxid *v) vxid_More(struct vxid_pool *v)
{ {
Lck_Lock(&vxid_lock); Lck_Lock(&vxid_lock);
...@@ -102,7 +104,7 @@ vxid_More(struct vxid *v) ...@@ -102,7 +104,7 @@ vxid_More(struct vxid *v)
} }
uint32_t uint32_t
VXID_Get(struct vxid *v) VXID_Get(struct vxid_pool *v)
{ {
if (v->count == 0) if (v->count == 0)
vxid_More(v); vxid_More(v);
......
...@@ -62,8 +62,6 @@ struct pool { ...@@ -62,8 +62,6 @@ struct pool {
pthread_cond_t herder_cond; pthread_cond_t herder_cond;
pthread_t herder_thr; pthread_t herder_thr;
struct vxid vxid;
struct lock mtx; struct lock mtx;
struct taskhead idle_queue; struct taskhead idle_queue;
struct taskhead front_queue; struct taskhead front_queue;
...@@ -148,7 +146,6 @@ pool_accept(struct worker *wrk, void *arg) ...@@ -148,7 +146,6 @@ pool_accept(struct worker *wrk, void *arg)
} }
Lck_Lock(&pp->mtx); Lck_Lock(&pp->mtx);
wa->vxid = VXID_Get(&pp->vxid);
wrk2 = pool_getidleworker(pp); wrk2 = pool_getidleworker(pp);
if (wrk2 == NULL) { if (wrk2 == NULL) {
/* No idle threads, do it ourselves */ /* No idle threads, do it ourselves */
......
...@@ -207,12 +207,15 @@ SES_pool_accept_task(struct worker *wrk, void *arg) ...@@ -207,12 +207,15 @@ SES_pool_accept_task(struct worker *wrk, void *arg)
sp->t_open = VTIM_real(); sp->t_open = VTIM_real();
sp->t_rx = sp->t_open; sp->t_rx = sp->t_open;
sp->t_idle = sp->t_open; sp->t_idle = sp->t_open;
sp->vxid = VXID_Get(&wrk->vxid_pool);
lsockname = VCA_SetupSess(wrk, sp); lsockname = VCA_SetupSess(wrk, sp);
req = ses_GetReq(sp); req = ses_GetReq(sp);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
req->vxid = VXID_Get(&wrk->vxid_pool);
ses_vsl_socket(req, lsockname); ses_vsl_socket(req, lsockname);
wrk->acct_tmp.sess++; wrk->acct_tmp.sess++;
...@@ -262,12 +265,16 @@ SES_Handle(struct sess *sp, double now) ...@@ -262,12 +265,16 @@ SES_Handle(struct sess *sp, double now)
struct req *req; struct req *req;
struct sesspool *pp; struct sesspool *pp;
/* NB: This only works with single-threaded waiters */
static struct vxid_pool vxid_pool;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
pp = sp->sesspool; pp = sp->sesspool;
CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC); CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC);
AN(pp->pool); AN(pp->pool);
req = ses_GetReq(sp); req = ses_GetReq(sp);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
req->vxid = VXID_Get(&vxid_pool);
sp->task.func = ses_pool_task; sp->task.func = ses_pool_task;
sp->task.priv = req; sp->task.priv = req;
sp->sess_step = S_STP_NEWREQ; sp->sess_step = S_STP_NEWREQ;
......
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