[master] 53234f7 Make mapping of VSM segments an explicit request, so that a VSL-only program will not need to map in all the VSC segments.
Poul-Henning Kamp
phk at FreeBSD.org
Thu Jun 8 15:59:06 CEST 2017
commit 53234f7d3de0b9d1fb9d852ca8da472ccecea7af
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Jun 8 13:57:42 2017 +0000
Make mapping of VSM segments an explicit request, so that a VSL-only
program will not need to map in all the VSC segments.
diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
index 7e0c15b..465f2d6 100644
--- a/bin/varnishadm/varnishadm.c
+++ b/bin/varnishadm/varnishadm.c
@@ -416,10 +416,12 @@ n_arg_sock(const char *n_arg)
VSM_Delete(vsm);
return (-1);
}
+ AZ(VSM_Map(vsm, &vt));
AN(vt.b);
T_start = T_arg = strdup(vt.b);
if (VSM_Get(vsm, &vt, "Arg", "-S", "")) {
+ AZ(VSM_Map(vsm, &vt));
AN(vt.b);
S_arg = strdup(vt.b);
}
diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h
index 5b08446..01427f4 100644
--- a/include/vapi/vsc.h
+++ b/include/vapi/vsc.h
@@ -53,7 +53,7 @@ int VSC_Arg(struct vsm *vd, int arg, const char *opt);
* 1 Handled.
*/
-void *VSC_Get(const struct vsm *vd, struct VSM_fantom *fantom,
+void *VSC_Get(struct vsm *vd, struct VSM_fantom *fantom,
const char *type, const char *ident);
/*
* Looks up the given VSC type and identifier. If fantom is
diff --git a/include/vapi/vsm.h b/include/vapi/vsm.h
index 4037c50..d556b4c 100644
--- a/include/vapi/vsm.h
+++ b/include/vapi/vsm.h
@@ -153,6 +153,8 @@ int VSM__itern(const struct vsm *vd, struct VSM_fantom *vf);
* vd = "struct vsm *"
*/
+int VSM_Map(struct vsm *vd, struct VSM_fantom *vf);
+
struct vsm_valid {
const char *name;
};
diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map
index 7d76489..01c39f7 100644
--- a/lib/libvarnishapi/libvarnishapi.map
+++ b/lib/libvarnishapi/libvarnishapi.map
@@ -182,4 +182,5 @@ LIBVARNISHAPI_1.7 {
VSM_invalid;
VSM_valid;
VSM_similar;
+ VSM_Map;
} LIBVARNISHAPI_1.0;
diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c
index 3e6bf0b..7a85443 100644
--- a/lib/libvarnishapi/vsc.c
+++ b/lib/libvarnishapi/vsc.c
@@ -230,7 +230,7 @@ VSC_Arg(struct vsm *vd, int arg, const char *opt)
*/
void *
-VSC_Get(const struct vsm *vd, struct VSM_fantom *fantom, const char *type,
+VSC_Get(struct vsm *vd, struct VSM_fantom *fantom, const char *type,
const char *ident)
{
struct VSM_fantom f2 = VSM_FANTOM_NULL;
@@ -240,6 +240,8 @@ VSC_Get(const struct vsm *vd, struct VSM_fantom *fantom, const char *type,
if (VSM_invalid == VSM_StillValid(vd, fantom) &&
!VSM_Get(vd, fantom, VSC_CLASS, type, ident))
return (NULL);
+ AZ(VSM_Map(vd, fantom));
+ AN(fantom->b);
return ((void*)((char*)fantom->b + 8));
}
@@ -313,6 +315,7 @@ vsc_build_vf_list(struct vsm *vd)
VSM_FOREACH(&vsc->iter_fantom, vd) {
if (strcmp(vsc->iter_fantom.class, VSC_CLASS))
continue;
+ AZ(VSM_Map(vd, &vsc->iter_fantom));
u = vbe64dec(vsc->iter_fantom.b);
assert(u > 0);
p = (char*)vsc->iter_fantom.b + 8 + u;
diff --git a/lib/libvarnishapi/vsl_cursor.c b/lib/libvarnishapi/vsl_cursor.c
index eb223a2..b193e44 100644
--- a/lib/libvarnishapi/vsl_cursor.c
+++ b/lib/libvarnishapi/vsl_cursor.c
@@ -252,6 +252,8 @@ VSL_CursorVSM(struct VSL_data *vsl, struct vsm *vsm, unsigned options)
"No VSL chunk found (child not started ?)");
return (NULL);
}
+ AZ(VSM_Map(vsm, &vf));
+ AN(vf.b);
head = vf.b;
if (memcmp(head->marker, VSL_HEAD_MARKER, sizeof head->marker)) {
diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index 4740b5e..1e31533 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -437,6 +437,18 @@ VSM__itern(const struct vsm *vd, struct VSM_fantom *vf)
/*--------------------------------------------------------------------*/
+int
+VSM_Map(struct vsm *vd, struct VSM_fantom *vf)
+{
+
+ CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
+ AN(vf);
+ AN(vf->b);
+ return (0);
+}
+
+/*--------------------------------------------------------------------*/
+
const struct vsm_valid *
VSM_StillValid(const struct vsm *vd, struct VSM_fantom *vf)
{
More information about the varnish-commit
mailing list