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

Decouple VSC api from VSM internal format

parent d24c9962
......@@ -39,7 +39,6 @@
#include "common/common.h"
#include "vapi/vsl_int.h"
#include "vapi/vsm_int.h"
#include "waiter/waiter.h"
......
......@@ -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.
*
*/
......
......@@ -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 \
......
......@@ -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;
};
......
......@@ -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
......
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2006-2015 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@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 */
......@@ -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
......
......@@ -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"
......
......@@ -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)
......
......@@ -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);
}
......
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