Commit b477c377 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Introduce SES_Ref() and SES_Rel(), so we can start to decorate

the code with them.
parent 82c21f91
......@@ -634,6 +634,7 @@ struct sess {
#define SESS_MAGIC 0x2c2f9c5a
uint16_t sattr[SA_LAST];
int refcnt;
int fd;
uint32_t vxid;
......@@ -944,7 +945,8 @@ struct sess *SES_New(struct pool *);
void SES_Close(struct sess *, enum sess_close reason);
void SES_Wait(struct sess *, const struct transport *);
void SES_Delete(struct sess *, enum sess_close reason, double now);
void SES_NewPool(struct pool *, unsigned pool_no);
void SES_Ref(struct sess *sp);
void SES_Rel(struct sess *sp);
int SES_Reschedule_Req(struct req *);
void SES_SetTransport(struct worker *, struct sess *, struct req *,
const struct transport *);
......
......@@ -89,6 +89,7 @@ ved_include(struct req *preq, const char *src, const char *host,
return;
req = Req_New(wrk, preq->sp);
SES_Ref(preq->sp);
req->req_body_status = REQ_BODY_NONE;
AZ(req->vsl->wid);
req->vsl->wid = VXID_Get(wrk, VSL_CLIENTMARKER);
......@@ -182,6 +183,7 @@ ved_include(struct req *preq, const char *src, const char *host,
req->wrk = NULL;
THR_SetRequest(preq);
SES_Rel(req->sp);
Req_Release(req);
}
......
......@@ -95,6 +95,9 @@ void Pool_Init(void);
/* cache_proxy.c [VPX] */
task_func_t VPX_Proto_Sess;
/* cache_session.c */
void SES_NewPool(struct pool *, unsigned pool_no);
/* cache_shmlog.c */
void VSM_Init(void);
void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len);
......
......@@ -325,6 +325,7 @@ SES_New(struct pool *pp)
sp = MPL_Get(pp->mpl_sess, &sz);
sp->magic = SESS_MAGIC;
sp->pool = pp;
sp->refcnt = 1;
memset(sp->sattr, 0xff, sizeof sp->sattr);
e = (char*)sp + sz;
......@@ -533,6 +534,31 @@ SES_Delete(struct sess *sp, enum sess_close reason, double now)
MPL_Free(pp->mpl_sess, sp);
}
/*--------------------------------------------------------------------
*/
void
SES_Ref(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
Lck_Lock(&sp->mtx);
assert(sp->refcnt > 0);
sp->refcnt++;
Lck_Unlock(&sp->mtx);
}
void
SES_Rel(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
Lck_Lock(&sp->mtx);
assert(sp->refcnt > 0);
sp->refcnt--;
Lck_Unlock(&sp->mtx);
}
/*--------------------------------------------------------------------
* Create and delete pools
*/
......
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