[master] e656835 Make the VRTPRIV_* interface slightly more generic to let us use it without needing a req/sess pointer.
Dag Haavi Finstad
daghf at varnish-software.com
Thu Nov 27 17:00:39 CET 2014
commit e6568354ace28d4e79fc8c0b47b3ce3c903f9f61
Author: Dag Haavi Finstad <daghf at varnish-software.com>
Date: Tue Nov 25 14:26:28 2014 +0100
Make the VRTPRIV_* interface slightly more generic to let us use it without needing a req/sess pointer.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index d8007c8..d69b4bd 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -119,7 +119,7 @@ struct sess;
struct sesspool;
struct vbc;
struct vrt_backend;
-struct vrt_privs;
+struct vrt_priv;
struct vsb;
struct waitinglist;
struct worker;
@@ -299,6 +299,14 @@ struct vxid_pool {
/*--------------------------------------------------------------------*/
+struct vrt_privs {
+ unsigned magic;
+#define VRT_PRIVS_MAGIC 0x03ba7501
+ VTAILQ_HEAD(,vrt_priv) privs;
+};
+
+/*--------------------------------------------------------------------*/
+
struct wrk_accept {
unsigned magic;
#define WRK_ACCEPT_MAGIC 0x8c4b4d59
@@ -663,7 +671,7 @@ struct sess {
double t_open; /* fd accepted */
double t_idle; /* fd accepted or resp sent */
- VTAILQ_HEAD(,vrt_privs) privs;
+ struct vrt_privs privs[1];
#if defined(HAVE_EPOLL_CTL)
struct epoll_event ev;
@@ -1046,7 +1054,8 @@ const char *VCL_Method_Name(unsigned);
*/
const char *VRT_String(struct ws *ws, const char *h, const char *p, va_list ap);
char *VRT_StringList(char *d, unsigned dl, const char *p, va_list ap);
-void VRTPRIV_dynamic_kill(struct sess *sp, uintptr_t id);
+void VRTPRIV_init(struct vrt_privs *privs);
+void VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id);
void ESI_Deliver(struct req *);
void ESI_DeliverChild(struct req *, struct busyobj *);
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 724b1a0..60c893e 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -91,7 +91,7 @@ ses_new(struct sesspool *pp)
sp->t_open = NAN;
sp->t_idle = NAN;
- VTAILQ_INIT(&sp->privs);
+ VRTPRIV_init(sp->privs);
Lck_New(&sp->mtx, lck_sess);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
return (sp);
@@ -300,7 +300,7 @@ SES_Delete(struct sess *sp, enum sess_close reason, double now)
now = VTIM_real();
AZ(isnan(sp->t_open));
- assert(VTAILQ_EMPTY(&sp->privs));
+ assert(VTAILQ_EMPTY(&sp->privs->privs));
VSL(SLT_SessClose, sp->vxid, "%s %.3f",
sess_close_2str(sp->reason, 0), now - sp->t_open);
VSL(SLT_End, sp->vxid, "%s", "");
diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c
index 482e34d..1819364 100644
--- a/bin/varnishd/cache/cache_vrt_priv.c
+++ b/bin/varnishd/cache/cache_vrt_priv.c
@@ -40,10 +40,10 @@
#include "vcl.h"
#include "vrt.h"
-struct vrt_privs {
+struct vrt_priv {
unsigned magic;
-#define VRT_PRIVS_MAGIC 0x24157a52
- VTAILQ_ENTRY(vrt_privs) list;
+#define VRT_PRIV_MAGIC 0x24157a52
+ VTAILQ_ENTRY(vrt_priv) list;
struct vmod_priv priv[1];
const struct VCL_conf *vcl;
uintptr_t id;
@@ -53,40 +53,51 @@ struct vrt_privs {
/*--------------------------------------------------------------------
*/
+void
+VRTPRIV_init(struct vrt_privs *privs)
+{
+ privs->magic = VRT_PRIVS_MAGIC;
+ VTAILQ_INIT(&privs->privs);
+}
+
static struct vmod_priv *
VRT_priv_dynamic(VRT_CTX, uintptr_t id, uintptr_t vmod_id)
{
- struct vrt_privs *vps;
+ struct vrt_priv *vp;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- VTAILQ_FOREACH(vps, &ctx->req->sp->privs, list) {
- CHECK_OBJ_NOTNULL(vps, VRT_PRIVS_MAGIC);
- if (vps->vcl == ctx->vcl && vps->id == id
- && vps->vmod_id == vmod_id)
- return (vps->priv);
+ CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx->req->sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx->req->sp->privs, VRT_PRIVS_MAGIC);
+
+ VTAILQ_FOREACH(vp, &ctx->req->sp->privs->privs, list) {
+ CHECK_OBJ_NOTNULL(vp, VRT_PRIV_MAGIC);
+ if (vp->vcl == ctx->vcl && vp->id == id
+ && vp->vmod_id == vmod_id)
+ return (vp->priv);
}
- ALLOC_OBJ(vps, VRT_PRIVS_MAGIC);
- AN(vps);
- vps->vcl = ctx->vcl;
- vps->id = id;
- vps->vmod_id = vmod_id;
- VTAILQ_INSERT_TAIL(&ctx->req->sp->privs, vps, list);
- return (vps->priv);
+ ALLOC_OBJ(vp, VRT_PRIV_MAGIC);
+ AN(vp);
+ vp->vcl = ctx->vcl;
+ vp->id = id;
+ vp->vmod_id = vmod_id;
+ VTAILQ_INSERT_TAIL(&ctx->req->sp->privs->privs, vp, list);
+ return (vp->priv);
}
void
-VRTPRIV_dynamic_kill(struct sess *sp, uintptr_t id)
+VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id)
{
- struct vrt_privs *vps, *vps1;
+ struct vrt_priv *vp, *vp1;
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(privs, VRT_PRIVS_MAGIC);
- VTAILQ_FOREACH_SAFE(vps, &sp->privs, list, vps1) {
- CHECK_OBJ_NOTNULL(vps, VRT_PRIVS_MAGIC);
- if (id == vps->id) {
- VTAILQ_REMOVE(&sp->privs, vps, list);
- VRT_priv_fini(vps->priv);
- FREE_OBJ(vps);
+ VTAILQ_FOREACH_SAFE(vp, &privs->privs, list, vp1) {
+ CHECK_OBJ_NOTNULL(vp, VRT_PRIV_MAGIC);
+ if (id == vp->id) {
+ VTAILQ_REMOVE(&privs->privs, vp, list);
+ VRT_priv_fini(vp->priv);
+ FREE_OBJ(vp);
}
}
}
@@ -107,4 +118,3 @@ VRT_priv_fini(const struct vmod_priv *p)
if (p->priv != (void*)0 && p->free != (void*)0)
p->free(p->priv);
}
-
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index a7ca699..29bd789 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -166,7 +166,7 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req)
req->vcl = NULL;
}
- VRTPRIV_dynamic_kill(sp, (uintptr_t)req);
+ VRTPRIV_dynamic_kill(sp->privs, (uintptr_t)req);
/* Charge and log byte counters */
AN(req->vsl->wid);
CNT_AcctLogCharge(wrk->stats, req);
More information about the varnish-commit
mailing list