varnish-cache/bin/varnishd/common/common_param.h
1
/*-
2
 * Copyright (c) 2006 Verdens Gang AS
3
 * Copyright (c) 2006-2011 Varnish Software AS
4
 * All rights reserved.
5
 *
6
 * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 *
29
 * This file contains the heritage passed when mgt forks cache
30
 */
31
32
#ifdef COMMON_COMMON_PARAM_H
33
#error "Multiple includes of common/common_param.h"
34
#endif
35
#define COMMON_COMMON_PARAM_H
36
37
#include "vre.h"
38
39
#define VSM_CLASS_PARAM         "Params"
40
41
enum debug_bits {
42
#define DEBUG_BIT(U, l, d) DBG_##U,
43
#include "tbl/debug_bits.h"
44
       DBG_Reserved
45
};
46
47
static inline int
48 2269688
COM_DO_DEBUG(const volatile uint8_t *p, enum debug_bits x)
49
{
50 2269688
        return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7)));
51
}
52
53
enum feature_bits {
54
#define FEATURE_BIT(U, l, d, ld) FEATURE_##U,
55
#include "tbl/feature_bits.h"
56
       FEATURE_Reserved
57
};
58
59
static inline int
60 27089
COM_FEATURE(const volatile uint8_t *p, enum feature_bits x)
61
{
62 27089
        return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7)));
63
}
64
65
66
struct poolparam {
67
        unsigned                min_pool;
68
        unsigned                max_pool;
69
        double                  max_age;
70
};
71
72
struct params {
73
74
#define ptyp_bool       unsigned
75
#define ptyp_bytes      ssize_t
76
#define ptyp_bytes_u    unsigned
77
#define ptyp_double     double
78
#define ptyp_poolparam  struct poolparam
79
#define ptyp_timeout    double
80
#define ptyp_uint       unsigned
81
#define ptyp_vsl_buffer unsigned
82
#define ptyp_vsl_reclen unsigned
83
#define PARAM(nm, ty, mi, ma, de, un, fl, st, lt, fn) ptyp_##ty nm;
84
#include <tbl/params.h>
85
#undef ptyp_bool
86
#undef ptyp_bytes
87
#undef ptyp_bytes_u
88
#undef ptyp_double
89
#undef ptyp_poolparam
90
#undef ptyp_timeout
91
#undef ptyp_uint
92
#undef ptyp_vsl_buffer
93
#undef ptyp_vsl_reclen
94
95
        /* Unprivileged user / group */
96
        uid_t                   uid;
97
        gid_t                   gid;
98
99
        /* Worker threads and pool */
100
        unsigned                wthread_min;
101
        unsigned                wthread_max;
102
        unsigned                wthread_reserve;
103
        double                  wthread_timeout;
104
        unsigned                wthread_pools;
105
        double                  wthread_add_delay;
106
        double                  wthread_fail_delay;
107
        double                  wthread_destroy_delay;
108
        unsigned                wthread_stats_rate;
109
        ssize_t                 wthread_stacksize;
110
        unsigned                wthread_queue_limit;
111
112
        struct vre_limits       vre_limits;
113
114
        struct poolparam        req_pool;
115
        struct poolparam        sess_pool;
116
        struct poolparam        vbo_pool;
117
118
        uint8_t                 vsl_mask[256>>3];
119
        uint8_t                 debug_bits[(DBG_Reserved+7)>>3];
120
        uint8_t                 feature_bits[(FEATURE_Reserved+7)>>3];
121
};