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

Retire common.h

parent 8bd3b43f
......@@ -139,7 +139,6 @@ nobase_pkginclude_HEADERS = \
cache/cache_filter.h \
cache/cache_backend.h \
cache/cache_director.h \
common/common.h \
common/common_vsm.h \
common/com_params.h \
waiter/waiter.h
......
......@@ -35,8 +35,16 @@
#define VARNISH_CACHE_CHILD 1
#include <stdarg.h>
#include <stdint.h>
#include "common/common.h"
#include <sys/types.h>
#include "miniobj.h"
#include "vas.h"
#include "vcs.h"
#include "vdef.h"
#include "vqueue.h"
#include "vsb.h"
#include "vapi/vsl_int.h"
......
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2006-2011 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.
*
*/
#ifdef COMMON_COMMON_H
#error "Multiple includes of common/common.h"
#endif
#define COMMON_COMMON_H
#include <stdint.h>
#include <sys/types.h>
#include "miniobj.h"
#include "vas.h"
#include "vcs.h"
#include "vdef.h"
#include "vqueue.h"
#include "vsb.h"
/**********************************************************************/
extern pid_t mgt_pid;
#define ASSERT_MGT() do { assert(getpid() == mgt_pid);} while (0)
/* Really belongs in mgt.h, but storage_file chokes on both */
void MCH_Fd_Inherit(int fd, const char *what);
#define ARGV_ERR(...) \
do { \
fprintf(stderr, "Error: " __VA_ARGS__); \
fprintf(stderr, "(-? gives usage)\n"); \
exit(2); \
} while (0)
......@@ -31,17 +31,21 @@
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "common.h"
#include "common/common_vsm.h"
#include "vdef.h"
#include "miniobj.h"
#include "vas.h"
#include "vend.h"
#include "vsmw.h"
#include "vgz.h"
#include "vmb.h"
#include "vqueue.h"
#include "vapi/vsc_int.h"
struct vsmw *proc_vsmw;
......
......@@ -87,10 +87,25 @@ struct heritage {
struct VCLS *cls;
const char *ident;
long mgt_pid;
};
extern struct heritage heritage;
#define ASSERT_MGT() do { assert(getpid() == heritage.mgt_pid);} while (0)
/* Really belongs in mgt.h, but storage_file chokes on both */
void MCH_Fd_Inherit(int fd, const char *what);
#define ARGV_ERR(...) \
do { \
ASSERT_MGT(); \
fprintf(stderr, "Error: " __VA_ARGS__); \
fprintf(stderr, "(-? gives usage)\n"); \
exit(2); \
} while (0)
/* cache/cache_main.c */
void child_main(void);
......
......@@ -32,6 +32,7 @@
#include "config.h"
#include "cache/cache.h"
#include "common/heritage.h"
#include <stdio.h>
#include <stdlib.h>
......
......@@ -33,7 +33,18 @@
#endif
#define MGT_MGT_H
#include "common/common.h"
#include <stdint.h>
#include <sys/types.h>
#include "miniobj.h"
#include "vas.h"
#include "vcs.h"
#include "vdef.h"
#include "vqueue.h"
#include "vsb.h"
#include "common/com_params.h"
#include "VSC_mgt.h"
......
......@@ -44,6 +44,7 @@
#include <unistd.h>
#include "mgt/mgt.h"
#include "common/heritage.h"
#include "vcli_serve.h"
#include "vev.h"
......
......@@ -40,6 +40,7 @@
#include <sys/stat.h>
#include "mgt/mgt.h"
#include "common/heritage.h"
#include "vav.h"
/**********************************************************************
......
......@@ -41,6 +41,7 @@
#include <sys/stat.h>
#include "mgt/mgt.h"
#include "common/heritage.h"
#ifdef __linux__
#include <sys/prctl.h>
......
......@@ -61,7 +61,6 @@
struct heritage heritage;
unsigned d_flag = 0;
pid_t mgt_pid;
struct vev_base *mgt_evb;
int exit_status = 0;
struct vsb *vident;
......@@ -202,7 +201,7 @@ mgt_secret_atexit(void)
{
/* Only master process */
if (getpid() != mgt_pid)
if (getpid() != heritage.mgt_pid)
return;
VJ_master(JAIL_MASTER_FILE);
(void)unlink("_.secret");
......@@ -240,7 +239,7 @@ mgt_Cflag_atexit(void)
{
/* Only master process */
if (getpid() != mgt_pid)
if (getpid() != heritage.mgt_pid)
return;
(void)rmdir("vmod_cache");
(void)unlink("_.pid");
......@@ -313,7 +312,7 @@ mgt_initialize(struct cli *cli)
static unsigned clilim = 32768;
/* for ASSERT_MGT() */
mgt_pid = getpid();
heritage.mgt_pid = getpid();
/* Create a cli for convenience in otherwise CLI functions */
INIT_OBJ(cli, CLI_MAGIC);
......@@ -593,7 +592,7 @@ main(int argc, char * const *argv)
if (!C_flag && !d_flag && !F_flag) {
eric_fd = mgt_eric();
MCH_TrackHighFd(eric_fd);
mgt_pid = getpid();
heritage.mgt_pid = getpid();
}
VRND_SeedAll();
......
......@@ -43,6 +43,7 @@
#include <unistd.h>
#include "mgt/mgt.h"
#include "common/heritage.h"
#include "vtcp.h"
......
......@@ -72,7 +72,7 @@ mgt_shm_atexit(void)
{
/* Do not let VCC kill our VSM */
if (getpid() != mgt_pid)
if (getpid() != heritage.mgt_pid)
return;
VJ_master(JAIL_MASTER_FILE);
VSMW_Destroy(&mgt_vsmw);
......
......@@ -40,6 +40,7 @@
#include <sys/stat.h>
#include "mgt/mgt.h"
#include "common/heritage.h"
#include "libvcc.h"
#include "vcli_serve.h"
......@@ -902,7 +903,7 @@ mgt_vcl_atexit(void)
{
struct vclprog *vp;
if (getpid() != mgt_pid)
if (getpid() != heritage.mgt_pid)
return;
active_vcl = NULL;
do {
......
......@@ -39,6 +39,7 @@
#include <unistd.h>
#include "mgt/mgt.h"
#include "common/heritage.h"
#include "vcli_serve.h"
#include "storage/storage.h"
......
......@@ -36,6 +36,7 @@
#include "config.h"
#include "cache/cache.h"
#include "common/heritage.h"
#include <sys/mman.h>
......
......@@ -41,6 +41,7 @@
#include <unistd.h>
#include "mgt/mgt.h"
#include "common/heritage.h"
#include "storage/storage.h"
#include "vnum.h"
......
......@@ -32,6 +32,7 @@
#include "config.h"
#include "cache/cache.h"
#include "common/heritage.h"
#include <sys/mman.h>
......
......@@ -32,6 +32,7 @@
#include "config.h"
#include "cache/cache.h"
#include "common/heritage.h"
#include <stdio.h>
#include <stdlib.h>
......
......@@ -37,6 +37,7 @@
#include <stddef.h>
#include "cache/cache.h"
#include "common/heritage.h"
#include <sys/mman.h>
......
......@@ -33,6 +33,7 @@
#include "mgt/mgt.h"
#include "waiter/mgt_waiter.h"
#include "common/heritage.h"
static const struct choice waiter_choice[] = {
#define WAITER(nm) { #nm, &waiter_##nm },
......
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