Refactor bereq/beresp flag tables

The filter check does not make sense in the context of bereq
and the macros became overloaded with two different cases.

Motivated by and in preparation of #3826
parent 4b1aa9ac
......@@ -394,8 +394,10 @@ struct busyobj {
struct pool_task fetch_task[1];
#define BO_FLAG(l, r, rr, rw, f, d) unsigned l:1;
#include "tbl/bo_flags.h"
#define BERESP_FLAG(l, r, w, f, d) unsigned l:1;
#define BEREQ_FLAG(l, r, w, d) BERESP_FLAG(l, r, w, 0, d)
#include "tbl/bereq_flags.h"
#include "tbl/beresp_flags.h"
/* Timeouts */
vtim_dur connect_timeout;
......
......@@ -390,9 +390,11 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo)
VSB_cat(vsb, "flags = {");
p = "";
/*lint -save -esym(438,p) -e539 */
#define BO_FLAG(l, r, rr, rw, f, d) \
#define BERESP_FLAG(l, r, w, f, d) \
if (bo->l) { VSB_printf(vsb, "%s" #l, p); p = ", "; }
#include "tbl/bo_flags.h"
#define BEREQ_FLAG(l, r, w, d) BERESP_FLAG(l, r, w, 0, d)
#include "tbl/bereq_flags.h"
#include "tbl/beresp_flags.h"
/*lint -restore */
VSB_cat(vsb, "},\n");
......
......@@ -181,7 +181,7 @@ VRT_r_obj_reason(VRT_CTX)
}
/*--------------------------------------------------------------------
* bool-fields (.do_*)
* beresp bool-fields
*/
static inline int
......@@ -228,21 +228,10 @@ VRT_r_beresp_##field(VRT_CTX) \
return (ctx->bo->field); \
}
#define VBEREQR0(field, str, fltchk)
#define VBEREQR1(field, str, fltchk) \
VCL_BOOL \
VRT_r_bereq_##field(VRT_CTX) \
{ \
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \
return (ctx->bo->field); \
}
#define BO_FLAG(l, r, rr, rw, f, d) \
VBEREQR##r(l, #l, f) \
VBERESPR##rr(l, #l, f) \
VBERESPW##rw(l, #l, f)
#include "tbl/bo_flags.h"
#define BERESP_FLAG(l, r, w, f, d) \
VBERESPR##r(l, #l, f) \
VBERESPW##w(l, #l, f)
#include "tbl/beresp_flags.h"
#undef VBERESPWF0
#undef VBERESPWF1
......@@ -254,6 +243,27 @@ VRT_r_bereq_##field(VRT_CTX) \
#undef VBERESPR0
#undef VBERESPR1
/*--------------------------------------------------------------------
* bereq bool-fields
*/
#define VBEREQR0(field, str)
#define VBEREQR1(field, str) \
VCL_BOOL \
VRT_r_bereq_##field(VRT_CTX) \
{ \
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \
return (ctx->bo->field); \
}
// w is unused
#define VBEREQW0(ctx, str) (void) 0
#define BEREQ_FLAG(l, r, w, d) \
VBEREQR##r(l, #l)
#include "tbl/bereq_flags.h"
#undef VBEREQR0
#undef VBEREQR1
/*--------------------------------------------------------------------*/
......
......@@ -8,8 +8,8 @@ nobase_pkginclude_HEADERS = \
tbl/ban_arg_oper.h \
tbl/ban_oper.h \
tbl/ban_vars.h \
tbl/bo_flags.h \
tbl/boc_state.h \
tbl/bereq_flags.h \
tbl/beresp_flags.h \
tbl/body_status.h \
tbl/cli_cmds.h \
tbl/debug_bits.h \
......
/*-
* Copyright (c) 2014-2015 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* 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.
*
*/
/*lint -save -e525 -e539 */
/* lower, vcl_r, vcl_w, doc */
BEREQ_FLAG(uncacheable, 0, 0, "") // also beresp
BEREQ_FLAG(is_bgfetch, 1, 0, "")
BEREQ_FLAG(is_hitmiss, 1, 0, "")
BEREQ_FLAG(is_hitpass, 1, 0, "")
#undef BEREQ_FLAG
/*lint -restore */
......@@ -34,16 +34,12 @@
/*
* filters: whether this flag determines beresp.filters default
*
* lower, vcl_r, vcl_beresp_r, vcl_beresp_w, filters, doc */
BO_FLAG(do_esi, 0, 1, 1, 1, "")
BO_FLAG(do_gzip, 0, 1, 1, 1, "")
BO_FLAG(do_gunzip, 0, 1, 1, 1, "")
BO_FLAG(do_stream, 0, 1, 1, 0, "")
BO_FLAG(uncacheable, 0, 0, 0, 0, "")
BO_FLAG(was_304, 0, 1, 0, 0, "")
BO_FLAG(is_bgfetch, 1, 0, 0, 0, "")
BO_FLAG(is_hitmiss, 1, 0, 0, 0, "")
BO_FLAG(is_hitpass, 1, 0, 0, 0, "")
#undef BO_FLAG
* lower, vcl_r, vcl_w, filters, doc */
BERESP_FLAG(do_esi, 1, 1, 1, "")
BERESP_FLAG(do_gzip, 1, 1, 1, "")
BERESP_FLAG(do_gunzip, 1, 1, 1, "")
BERESP_FLAG(do_stream, 1, 1, 0, "")
BERESP_FLAG(was_304, 1, 0, 0, "")
#undef BERESP_FLAG
/*lint -restore */
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