[master] eacdb4f Decouple VSC api from VSM internal format
Poul-Henning Kamp
phk at FreeBSD.org
Mon May 8 00:44:05 CEST 2017
commit eacdb4ff5bf962bbeeda5f2e9d27184e0e7915e0
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sun May 7 22:43:32 2017 +0000
Decouple VSC api from VSM internal format
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 72140ee..b772822 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -39,7 +39,6 @@
#include "common/common.h"
#include "vapi/vsl_int.h"
-#include "vapi/vsm_int.h"
#include "waiter/waiter.h"
diff --git a/bin/varnishd/common/common_vsm.c b/bin/varnishd/common/common_vsm.c
index 7b38c4a..22ae5c3 100644
--- a/bin/varnishd/common/common_vsm.c
+++ b/bin/varnishd/common/common_vsm.c
@@ -27,7 +27,7 @@
*
* VSM stuff common to manager and child.
*
- * Please see comments in <vapi/vsm_int.h> for details of protocols and
+ * Please see comments in <vsm_priv.h> for details of protocols and
* data consistency.
*
*/
diff --git a/include/Makefile.am b/include/Makefile.am
index f6a08eb..9adaebe 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -46,7 +46,6 @@ nobase_pkginclude_HEADERS = \
tbl/vsl_tags_http.h \
tbl/waiters.h \
vapi/vsm.h \
- vapi/vsm_int.h \
vapi/vsc.h \
vapi/vsc_int.h \
vapi/vsl.h \
diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h
index ebd003e..900a795 100644
--- a/include/vapi/vsc.h
+++ b/include/vapi/vsc.h
@@ -114,8 +114,8 @@ struct VSC_type_desc {
};
struct VSC_section {
- const char *type;
- const char *ident;
+ char *type;
+ char *ident;
const struct VSC_type_desc *desc;
};
diff --git a/include/vapi/vsm.h b/include/vapi/vsm.h
index 18d809b..79cba08 100644
--- a/include/vapi/vsm.h
+++ b/include/vapi/vsm.h
@@ -36,8 +36,6 @@
#ifndef VAPI_VSM_H_INCLUDED
#define VAPI_VSM_H_INCLUDED
-#include "vsm_int.h"
-
struct VSM_chunk;
struct VSM_data;
@@ -50,12 +48,12 @@ struct VSM_fantom {
void *b; /* first byte of payload */
void *e; /* first byte past payload */
uintptr_t priv; /* VSM private */
- char class[VSM_MARKER_LEN];
- char type[VSM_MARKER_LEN];
- char ident[VSM_IDENT_LEN];
+ char *class;
+ char *type;
+ char *ident;
};
-#define VSM_FANTOM_NULL { 0, 0, 0, 0, {0}, {0}, {0} }
+#define VSM_FANTOM_NULL { 0, 0, 0, 0, 0, 0, 0 }
/*---------------------------------------------------------------------
* VSM level access functions
diff --git a/include/vapi/vsm_int.h b/include/vapi/vsm_int.h
deleted file mode 100644
index deed9f7..0000000
--- a/include/vapi/vsm_int.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2015 Varnish Software AS
- * All rights reserved.
- *
- * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Define the internal details which must be kept in sync between
- * vsm_priv.h and vapi/vsm.h, and this file SHALL not be included
- * from anywhere but those two files.
- *
- * NB: THIS IS NOT A PUBLIC API TO VARNISH!
- *
- */
-
-#ifndef VSM_INT_H_INCLUDED
-#define VSM_INT_H_INCLUDED
-
-#define VSM_FILENAME "_.vsm"
-#define VSM_MARKER_LEN 8
-#define VSM_IDENT_LEN 128
-
-#endif /* VSM_INT_H_INCLUDED */
diff --git a/include/vsl_priv.h b/include/vsl_priv.h
index 6296a5b..8ac6c66 100644
--- a/include/vsl_priv.h
+++ b/include/vsl_priv.h
@@ -36,7 +36,7 @@
#define VSL_PRIV_H_INCLUDED
#include "vapi/vsl_int.h"
-#include "vapi/vsm_int.h"
+#include "vsm_priv.h"
#define VSL_CLASS "Log"
#define VSL_SEGMENTS 8U // power of two
diff --git a/include/vsm_priv.h b/include/vsm_priv.h
index 4d0d401..20f4f90 100644
--- a/include/vsm_priv.h
+++ b/include/vsm_priv.h
@@ -96,7 +96,9 @@
#ifndef VSM_PRIV_H_INCLUDED
#define VSM_PRIV_H_INCLUDED
-#include <vapi/vsm_int.h>
+#define VSM_FILENAME "_.vsm"
+#define VSM_MARKER_LEN 8
+#define VSM_IDENT_LEN 128
struct VSM_chunk {
#define VSM_CHUNK_MARKER "VSMCHUNK"
diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c
index 9f0a4ff..5fd55fd 100644
--- a/lib/libvarnishapi/vsc.c
+++ b/lib/libvarnishapi/vsc.c
@@ -253,8 +253,8 @@ vsc_add_vf(struct vsc *vsc, const struct VSM_fantom *fantom,
ALLOC_OBJ(vf, VSC_VF_MAGIC);
AN(vf);
vf->fantom = *fantom;
- vf->section.type = vf->fantom.type;
- vf->section.ident = vf->fantom.ident;
+ REPLACE(vf->section.type, vf->fantom.type);
+ REPLACE(vf->section.ident, vf->fantom.ident);
vf->section.desc = desc;
vf->order = order;
@@ -336,7 +336,7 @@ vsc_build_pt_list(struct VSM_data *vd)
VTAILQ_FOREACH(vf, &vsc->vf_list, list) {
#define VSC_DO(U,l,t,h) \
CHECK_OBJ_NOTNULL(vf, VSC_VF_MAGIC); \
- if (!strcmp(vf->fantom.type, t)) \
+ if (!strcmp(vf->section.type, t)) \
iter_##l(vsc, VSC_desc_##l, vf);
#define VSC_F(n,t,l,s,f,v,d,e)
#define VSC_DONE(a,b,c)
diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index ae0ace8..3805237 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -397,12 +397,15 @@ VSM__itern(const struct VSM_data *vd, struct VSM_fantom *vf)
vf->priv = vd->head->alloc_seq;
vf->b = (void*)(vf->chunk + 1);
vf->e = (char*)vf->b + vf->chunk->len;
- strncpy(vf->class, vf->chunk->class, sizeof vf->class);
- vf->class[sizeof vf->class - 1] = '\0';
- strncpy(vf->type, vf->chunk->type, sizeof vf->type);
- vf->type[sizeof vf->type - 1] = '\0';
- strncpy(vf->ident, vf->chunk->ident, sizeof vf->ident);
- vf->ident[sizeof vf->ident - 1] = '\0';
+
+ AZ(vf->chunk->class[sizeof vf->chunk->class - 1]);
+ REPLACE(vf->class, vf->chunk->class);
+
+ AZ(vf->chunk->type[sizeof vf->chunk->type - 1]);
+ REPLACE(vf->type, vf->chunk->type);
+
+ AZ(vf->chunk->ident[sizeof vf->chunk->ident - 1]);
+ REPLACE(vf->ident, vf->chunk->ident);
return (1);
}
More information about the varnish-commit
mailing list