[master] d8dfd9c Retire common.h
Poul-Henning Kamp
phk at FreeBSD.org
Wed Sep 27 08:45:11 UTC 2017
commit d8dfd9c12cd55474fb790b82ddfdff37dd6af084
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Sep 27 07:51:47 2017 +0000
Retire common.h
diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am
index 7fe38a5..24b814b 100644
--- a/bin/varnishd/Makefile.am
+++ b/bin/varnishd/Makefile.am
@@ -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
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index c228b69..7fcdd52 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.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"
diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h
deleted file mode 100644
index 9b71491..0000000
--- a/bin/varnishd/common/common.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2011 Varnish Software AS
- * All rights reserved.
- *
- * Author: Poul-Henning Kamp <phk at 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)
diff --git a/bin/varnishd/common/common_vsc.c b/bin/varnishd/common/common_vsc.c
index bc8dabf..1523cea 100644
--- a/bin/varnishd/common/common_vsc.c
+++ b/bin/varnishd/common/common_vsc.c
@@ -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;
diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h
index f2df8c1..b12e9ea 100644
--- a/bin/varnishd/common/heritage.h
+++ b/bin/varnishd/common/heritage.h
@@ -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);
diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c
index 87db657..a4e9861 100644
--- a/bin/varnishd/hash/hash_classic.c
+++ b/bin/varnishd/hash/hash_classic.c
@@ -32,6 +32,7 @@
#include "config.h"
#include "cache/cache.h"
+#include "common/heritage.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index 4573fbd..5256a0a 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.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"
diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c
index f00e19a..dd031ed 100644
--- a/bin/varnishd/mgt/mgt_cli.c
+++ b/bin/varnishd/mgt/mgt_cli.c
@@ -44,6 +44,7 @@
#include <unistd.h>
#include "mgt/mgt.h"
+#include "common/heritage.h"
#include "vcli_serve.h"
#include "vev.h"
diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c
index d241cf7..b413821 100644
--- a/bin/varnishd/mgt/mgt_jail.c
+++ b/bin/varnishd/mgt/mgt_jail.c
@@ -40,6 +40,7 @@
#include <sys/stat.h>
#include "mgt/mgt.h"
+#include "common/heritage.h"
#include "vav.h"
/**********************************************************************
diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c
index f9c0157..27cebb1 100644
--- a/bin/varnishd/mgt/mgt_jail_unix.c
+++ b/bin/varnishd/mgt/mgt_jail_unix.c
@@ -41,6 +41,7 @@
#include <sys/stat.h>
#include "mgt/mgt.h"
+#include "common/heritage.h"
#ifdef __linux__
#include <sys/prctl.h>
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index f27f04f..be1bb67 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -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();
diff --git a/bin/varnishd/mgt/mgt_param_tcp.c b/bin/varnishd/mgt/mgt_param_tcp.c
index 70ababc..ef55533 100644
--- a/bin/varnishd/mgt/mgt_param_tcp.c
+++ b/bin/varnishd/mgt/mgt_param_tcp.c
@@ -43,6 +43,7 @@
#include <unistd.h>
#include "mgt/mgt.h"
+#include "common/heritage.h"
#include "vtcp.h"
diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c
index 6853a1f..eda3428 100644
--- a/bin/varnishd/mgt/mgt_shmem.c
+++ b/bin/varnishd/mgt/mgt_shmem.c
@@ -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);
diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 61aae33..8a879ab 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -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 {
diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c
index 4146ff9..c3e161d 100644
--- a/bin/varnishd/storage/mgt_stevedore.c
+++ b/bin/varnishd/storage/mgt_stevedore.c
@@ -39,6 +39,7 @@
#include <unistd.h>
#include "mgt/mgt.h"
+#include "common/heritage.h"
#include "vcli_serve.h"
#include "storage/storage.h"
diff --git a/bin/varnishd/storage/mgt_storage_persistent.c b/bin/varnishd/storage/mgt_storage_persistent.c
index 747032b..d0155cd 100644
--- a/bin/varnishd/storage/mgt_storage_persistent.c
+++ b/bin/varnishd/storage/mgt_storage_persistent.c
@@ -36,6 +36,7 @@
#include "config.h"
#include "cache/cache.h"
+#include "common/heritage.h"
#include <sys/mman.h>
diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c
index d620447..80e8fd8 100644
--- a/bin/varnishd/storage/stevedore_utils.c
+++ b/bin/varnishd/storage/stevedore_utils.c
@@ -41,6 +41,7 @@
#include <unistd.h>
#include "mgt/mgt.h"
+#include "common/heritage.h"
#include "storage/storage.h"
#include "vnum.h"
diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c
index 675bf62..b0480b8 100644
--- a/bin/varnishd/storage/storage_file.c
+++ b/bin/varnishd/storage/storage_file.c
@@ -32,6 +32,7 @@
#include "config.h"
#include "cache/cache.h"
+#include "common/heritage.h"
#include <sys/mman.h>
diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c
index 083b741..7da5c4a 100644
--- a/bin/varnishd/storage/storage_malloc.c
+++ b/bin/varnishd/storage/storage_malloc.c
@@ -32,6 +32,7 @@
#include "config.h"
#include "cache/cache.h"
+#include "common/heritage.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/bin/varnishd/storage/storage_persistent_subr.c b/bin/varnishd/storage/storage_persistent_subr.c
index 7a7b866..63ff47d 100644
--- a/bin/varnishd/storage/storage_persistent_subr.c
+++ b/bin/varnishd/storage/storage_persistent_subr.c
@@ -37,6 +37,7 @@
#include <stddef.h>
#include "cache/cache.h"
+#include "common/heritage.h"
#include <sys/mman.h>
diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c
index 01780d3..1ea8320 100644
--- a/bin/varnishd/waiter/mgt_waiter.c
+++ b/bin/varnishd/waiter/mgt_waiter.c
@@ -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 },
More information about the varnish-commit
mailing list