Code Coverage: vinyl-cache/bin/vinyld/cache/cache_vcl.h
 
82217aa4fc7094b3610340078afaf78cd95a8ec9
 
0
/*-
1
 * Copyright (c) 2006 Verdens Gang AS
2
 * Copyright (c) 2006-2016 Varnish Software AS
3
 * All rights reserved.
4
 *
5
 * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
6
 *
7
 * SPDX-License-Identifier: BSD-2-Clause
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions
11
 * are met:
12
 * 1. Redistributions of source code must retain the above copyright
13
 *    notice, this list of conditions and the following disclaimer.
14
 * 2. Redistributions in binary form must reproduce the above copyright
15
 *    notice, this list of conditions and the following disclaimer in the
16
 *    documentation and/or other materials provided with the distribution.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
22
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
 * SUCH DAMAGE.
29
 *
30
 * NB: This is a private .h file for cache_vcl*.c
31
 * NB: No other code should include this file.
32
 *
33
 */
34
35
struct vfilter;
36
struct vcltemp;
37
38
VTAILQ_HEAD(vfilter_head, vfilter);
39
VTAILQ_HEAD(vcldir_head, vcldir);
40
41
struct vdire {
42
        unsigned                magic;
43
#define VDIRE_MAGIC             0x51748697
44
        unsigned                iterating;
45
        struct vcldir_head      directors;
46
        struct vcldir_head      resigning;
47
        // vcl_mtx for now - to be refactored into separate mtx?
48
        struct lock             *mtx;
49
        // to signal when iterators can enter again
50
        pthread_cond_t          cond;
51
        const struct vcltemp    **tempp;
52
        // last director present when vdire_start_event is called
53
        struct vcldir           *checkpoint;
54
};
55
56
struct vcl {
57
        unsigned                magic;
58
#define VCL_MAGIC               0x214188f2
59
        VTAILQ_ENTRY(vcl)       list;
60
        void                    *dlh;
61
        const struct VCL_conf   *conf;
62
        char                    state[8];
63
        char                    *loaded_name;
64
        unsigned                busy;
65
        unsigned                discard;
66
        const struct vcltemp    *temp;
67
        VTAILQ_HEAD(,vclref)    ref_list;
68
        struct vdire            *vdire;
69
        struct vcl              *label;
70
        int                     nrefs;
71
        int                     nlabels;
72
        struct vfilter_head     filters;
73
};
74
75
struct vclref {
76
        unsigned                magic;
77
#define VCLREF_MAGIC            0x47fb6848
78
        struct vcl              *vcl;
79
        VTAILQ_ENTRY(vclref)    list;
80
        char                    *desc;
81
};
82
83
extern struct lock              vcl_mtx;
84
extern struct vcl               *vcl_active; /* protected by vcl_mtx */
85
struct vcl *vcl_find(const char *);
86
void VCL_Update(struct vcl **, struct vcl *);
87
88
struct vcltemp {
89
        const char * const      name;
90
        unsigned                is_warm;
91
        unsigned                is_cold;
92
};
93
94
/*
95
 * NB: The COOLING temperature is neither COLD nor WARM.
96
 * And LABEL is not a temperature, it's a different kind of VCL.
97
 */
98
extern const struct vcltemp VCL_TEMP_INIT[1];
99
extern const struct vcltemp VCL_TEMP_COLD[1];
100
extern const struct vcltemp VCL_TEMP_WARM[1];
101
extern const struct vcltemp VCL_TEMP_BUSY[1];
102
extern const struct vcltemp VCL_TEMP_COOLING[1];
103
104
#define ASSERT_VCL_ACTIVE()                                     \
105 25090
        do {                                                    \
106 25090
                assert(vcl_active == NULL ||                    \
107 25090
                    vcl_active->temp->is_warm);                 \
108 25090
        } while (0)
109
110
/* cache_vrt_vcl.c used in cache_vcl.c */
111
struct vcldir;
112
void vcldir_retire(struct vcldir *vdir, const struct vcltemp *temp);
113
114
/* cache_vcl.c */
115
void vdire_resign(struct vdire *vdire, struct vcldir *vdir);
116
117
void vdire_start_iter(struct vdire *vdire);
118
void vdire_end_iter(struct vdire *vdire);