Code Coverage: vinyl-cache/bin/vinyld/common/heritage.h
 
82217aa4fc7094b3610340078afaf78cd95a8ec9
 
0
/*-
1
 * Copyright (c) 2006 Verdens Gang AS
2
 * Copyright (c) 2006-2011 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
 * This file contains the heritage passed when mgt forks cache
31
 */
32
33
struct vsmw;
34
struct suckaddr;
35
struct listen_sock;
36
struct transport;
37
struct VCLS;
38
struct uds_perms;
39
struct conn_heritage;
40
41
struct listen_sock {
42
        unsigned                        magic;
43
#define LISTEN_SOCK_MAGIC               0x999e4b57
44
        VTAILQ_ENTRY(listen_sock)       list;
45
        VTAILQ_ENTRY(listen_sock)       arglist;
46
        VTAILQ_ENTRY(listen_sock)       vcalist;
47
        int                             sock;
48
        int                             uds;
49
        char                            *endpoint;
50
        const char                      *name;
51
        const struct suckaddr           *addr;
52
        const struct transport          *transport;
53
        const struct uds_perms          *perms;
54
        unsigned                        test_heritage;
55
        struct conn_heritage            *conn_heritage;
56
        struct acceptor                 *vca;
57
        void                            *vca_priv;
58
};
59
60
VTAILQ_HEAD(listen_sock_head, listen_sock);
61
62
struct heritage {
63
64
        /* Two pipe(2)'s for CLI connection between cache and mgt.  */
65
        int                             cli_fd;
66
67
        /* File descriptor for stdout/stderr */
68
        int                             std_fd;
69
70
        int                             vsm_fd;
71
72
        /* Sockets from which to accept connections */
73
        struct listen_sock_head         socks;
74
75
        /* Hash method */
76
        const struct hash_slinger       *hash;
77
78
        struct params                   *param;
79
80
        const char                      *identity;
81
82
        char                            *panic_str;
83
        ssize_t                         panic_str_len;
84
85
        struct VCLS                     *cls;
86
87
        const char                      *ident;
88
89
        long                            mgt_pid;
90
91
        struct vsmw                     *proc_vsmw;
92
93
        unsigned                        min_vcl_version;
94
        unsigned                        max_vcl_version;
95
96
        int                             argc;
97
        char * const *                  argv;
98
};
99
100
extern struct heritage heritage;
101
102 9532
#define ASSERT_MGT() do { assert(getpid() == heritage.mgt_pid);} while (0)
103
104
/* Really belongs in mgt.h, but storage_file chokes on both */
105
void MCH_Fd_Inherit(int fd, const char *what);
106
107
#define ARGV_EXIT                                               \
108 74
        do {                                                    \
109 74
                fprintf(stderr, "(-? gives usage)\n");          \
110 74
                exit(2);                                        \
111 74
        } while (0)
112
113
#define ARGV_ERR(...)                                           \
114 3221
        do {                                                    \
115 74
                fprintf(stderr, "Error: " __VA_ARGS__);         \
116 74
                ARGV_EXIT;                                      \
117 74
        } while (0)
118
119
/* cache/cache_main.c */
120
void child_main(int, size_t);
121
122
/* cache/cache_vcl.c */
123
int VCL_TestLoad(const char *);
124
125
/* acceptor/cache_acceptor.c */
126
struct transport;
127
void XPORT_Init(void);
128
const struct transport *XPORT_Find(const char *name);
129
130
/* common/common_vsc.c & common/common_vsmw.c */
131
typedef void vsm_lock_f(void);
132
extern vsm_lock_f *vsc_lock;
133
extern vsm_lock_f *vsc_unlock;
134
extern vsm_lock_f *vsmw_lock;
135
extern vsm_lock_f *vsmw_unlock;