[master] 55d8e88 Split waiter::cache and waiter:mgt out from waiter::common
Poul-Henning Kamp
phk at varnish-cache.org
Mon Dec 19 11:04:53 CET 2011
commit 55d8e88dfface89b6d4a38f3afc48863ccdc2b04
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Dec 19 10:04:28 2011 +0000
Split waiter::cache and waiter:mgt out from waiter::common
diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am
index 0c3427e..8a925b9 100644
--- a/bin/varnishd/Makefile.am
+++ b/bin/varnishd/Makefile.am
@@ -76,7 +76,8 @@ varnishd_SOURCES = \
storage/storage_persistent_subr.c \
storage/storage_synth.c \
storage/storage_umem.c \
- waiter/waiter_common.c \
+ waiter/mgt_waiter.c \
+ waiter/cache_waiter.c \
waiter/cache_waiter_epoll.c \
waiter/cache_waiter_kqueue.c \
waiter/cache_waiter_poll.c \
@@ -96,7 +97,7 @@ noinst_HEADERS = \
mgt/mgt_param.h \
storage/storage.h \
storage/storage_persistent.h \
- waiter/cache_waiter.h
+ waiter/waiter.h
varnishd_CFLAGS = \
@PCRE_CFLAGS@ \
diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c
index 2189104..48e934d 100644
--- a/bin/varnishd/cache/cache_main.c
+++ b/bin/varnishd/cache/cache_main.c
@@ -35,7 +35,7 @@
#include "cache.h"
#include "common/heritage.h"
-#include "waiter/cache_waiter.h"
+#include "waiter/waiter.h"
#include "hash/hash_slinger.h"
volatile struct params *cache_param;
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 94a4c09..6daf807 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -42,7 +42,7 @@
#include "common/heritage.h"
#include "cache_backend.h"
-#include "waiter/cache_waiter.h"
+#include "waiter/waiter.h"
#include "vcl.h"
/*
diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c
index afa069a..a4d8a28 100644
--- a/bin/varnishd/cache/cache_pool.c
+++ b/bin/varnishd/cache/cache_pool.c
@@ -48,7 +48,7 @@
#include "cache.h"
#include "common/heritage.h"
-#include "waiter/cache_waiter.h"
+#include "waiter/waiter.h"
#include "vtcp.h"
#include "vtim.h"
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 21d7f51..19292ea 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -40,7 +40,7 @@
#include "cache.h"
-#include "waiter/cache_waiter.h"
+#include "waiter/waiter.h"
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index 128364c..f7f1dd0 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -43,7 +43,7 @@
#include "common/params.h"
#include "mgt/mgt_param.h"
-#include "waiter/cache_waiter.h"
+#include "waiter/waiter.h"
#include "vav.h"
#include "vcli.h"
#include "vcli_common.h"
diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c
new file mode 100644
index 0000000..bf5717b
--- /dev/null
+++ b/bin/varnishd/waiter/cache_waiter.c
@@ -0,0 +1,58 @@
+/*-
+ * 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.
+ *
+ */
+
+#include "config.h"
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "common/common.h"
+
+#include "waiter/waiter.h"
+
+const char *
+WAIT_GetName(void)
+{
+
+ if (waiter != NULL)
+ return (waiter->name);
+ else
+ return ("no_waiter");
+}
+
+void
+WAIT_Init(void)
+{
+
+ AN(waiter);
+ AN(waiter->name);
+ AN(waiter->init);
+ AN(waiter->pass);
+}
diff --git a/bin/varnishd/waiter/cache_waiter.h b/bin/varnishd/waiter/cache_waiter.h
deleted file mode 100644
index 1d6e679..0000000
--- a/bin/varnishd/waiter/cache_waiter.h
+++ /dev/null
@@ -1,64 +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.
- *
- */
-
-struct sess;
-
-typedef void* waiter_init_f(void);
-typedef void waiter_pass_f(void *priv, const struct sess *);
-
-struct waiter {
- const char *name;
- waiter_init_f *init;
- waiter_pass_f *pass;
-};
-
-extern struct waiter const * waiter;
-
-#if defined(HAVE_EPOLL_CTL)
-extern const struct waiter waiter_epoll;
-#endif
-
-#if defined(HAVE_KQUEUE)
-extern const struct waiter waiter_kqueue;
-#endif
-
-#if defined(HAVE_PORT_CREATE)
-extern const struct waiter waiter_ports;
-#endif
-
-
-/* cache_session.c */
-void SES_Handle(struct sess *sp, int status);
-
-/* cache_waiter.c */
-extern const struct waiter waiter_poll;
-const char *WAIT_GetName(void);
-void WAIT_tweak_waiter(struct cli *cli, const char *arg);
-void WAIT_Init(void);
diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c
index 06cd8bb..ca0d29f 100644
--- a/bin/varnishd/waiter/cache_waiter_epoll.c
+++ b/bin/varnishd/waiter/cache_waiter_epoll.c
@@ -42,7 +42,7 @@
#include "cache/cache.h"
-#include "waiter/cache_waiter.h"
+#include "waiter/waiter.h"
#include "vtim.h"
#ifndef EPOLLRDHUP
diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c
index 7ceb80c..e9ec1ec 100644
--- a/bin/varnishd/waiter/cache_waiter_kqueue.c
+++ b/bin/varnishd/waiter/cache_waiter_kqueue.c
@@ -44,7 +44,7 @@
#include "cache/cache.h"
-#include "waiter/cache_waiter.h"
+#include "waiter/waiter.h"
#include "vtim.h"
#define NKEV 100
diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c
index f6be13d..681b48d 100644
--- a/bin/varnishd/waiter/cache_waiter_poll.c
+++ b/bin/varnishd/waiter/cache_waiter_poll.c
@@ -35,7 +35,7 @@
#include "cache/cache.h"
-#include "waiter/cache_waiter.h"
+#include "waiter/waiter.h"
#include "vtim.h"
#define NEEV 128
diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c
index ce2afc3..7717196 100644
--- a/bin/varnishd/waiter/cache_waiter_ports.c
+++ b/bin/varnishd/waiter/cache_waiter_ports.c
@@ -42,7 +42,7 @@
#include "cache/cache.h"
-#include "waiter/cache_waiter.h"
+#include "waiter/waiter.h"
#include "vtim.h"
#define MAX_EVENTS 256
diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c
new file mode 100644
index 0000000..d2816a8
--- /dev/null
+++ b/bin/varnishd/waiter/mgt_waiter.c
@@ -0,0 +1,90 @@
+/*-
+ * 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.
+ *
+ */
+
+#include "config.h"
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "common/common.h"
+
+#include "waiter/waiter.h"
+#include "vcli.h"
+#include "vcli_priv.h"
+
+static const struct waiter *const vca_waiters[] = {
+ #if defined(HAVE_KQUEUE)
+ &waiter_kqueue,
+ #endif
+ #if defined(HAVE_EPOLL_CTL)
+ &waiter_epoll,
+ #endif
+ #if defined(HAVE_PORT_CREATE)
+ &waiter_ports,
+ #endif
+ &waiter_poll,
+ NULL,
+};
+
+struct waiter const *waiter;
+
+void
+WAIT_tweak_waiter(struct cli *cli, const char *arg)
+{
+ int i;
+
+ ASSERT_MGT();
+
+ if (arg == NULL) {
+ if (waiter == NULL)
+ VCLI_Out(cli, "default");
+ else
+ VCLI_Out(cli, "%s", waiter->name);
+
+ VCLI_Out(cli, " (");
+ for (i = 0; vca_waiters[i] != NULL; i++)
+ VCLI_Out(cli, "%s%s", i == 0 ? "" : ", ",
+ vca_waiters[i]->name);
+ VCLI_Out(cli, ")");
+ return;
+ }
+ if (!strcmp(arg, "default")) {
+ waiter = vca_waiters[0];
+ return;
+ }
+ for (i = 0; vca_waiters[i]; i++) {
+ if (!strcmp(arg, vca_waiters[i]->name)) {
+ waiter = vca_waiters[i];
+ return;
+ }
+ }
+ VCLI_Out(cli, "Unknown waiter");
+ VCLI_SetResult(cli, CLIS_PARAM);
+}
diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h
new file mode 100644
index 0000000..e9c3cdc
--- /dev/null
+++ b/bin/varnishd/waiter/waiter.h
@@ -0,0 +1,65 @@
+/*-
+ * 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.
+ *
+ */
+
+struct sess;
+
+typedef void* waiter_init_f(void);
+typedef void waiter_pass_f(void *priv, const struct sess *);
+
+struct waiter {
+ const char *name;
+ waiter_init_f *init;
+ waiter_pass_f *pass;
+};
+
+/* mgt_waiter.c */
+extern struct waiter const * waiter;
+void WAIT_tweak_waiter(struct cli *cli, const char *arg);
+
+#if defined(HAVE_EPOLL_CTL)
+extern const struct waiter waiter_epoll;
+#endif
+
+#if defined(HAVE_KQUEUE)
+extern const struct waiter waiter_kqueue;
+#endif
+
+#if defined(HAVE_PORT_CREATE)
+extern const struct waiter waiter_ports;
+#endif
+
+extern const struct waiter waiter_poll;
+
+/* cache_session.c */
+void SES_Handle(struct sess *sp, int status);
+
+/* cache_waiter.c */
+const char *WAIT_GetName(void);
+void WAIT_Init(void);
diff --git a/bin/varnishd/waiter/waiter_common.c b/bin/varnishd/waiter/waiter_common.c
deleted file mode 100644
index e09a296..0000000
--- a/bin/varnishd/waiter/waiter_common.c
+++ /dev/null
@@ -1,113 +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.
- *
- */
-
-#include "config.h"
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "common/common.h"
-
-#include "waiter/cache_waiter.h"
-#include "vcli.h"
-#include "vcli_priv.h"
-
-static const struct waiter * const vca_waiters[] = {
- #if defined(HAVE_KQUEUE)
- &waiter_kqueue,
- #endif
- #if defined(HAVE_EPOLL_CTL)
- &waiter_epoll,
- #endif
- #if defined(HAVE_PORT_CREATE)
- &waiter_ports,
- #endif
- &waiter_poll,
- NULL,
-};
-
-struct waiter const * waiter;
-
-const char *
-WAIT_GetName(void)
-{
-
- if (waiter != NULL)
- return (waiter->name);
- else
- return ("no_waiter");
-}
-
-void
-WAIT_tweak_waiter(struct cli *cli, const char *arg)
-{
- int i;
-
- ASSERT_MGT();
-
- if (arg == NULL) {
- if (waiter == NULL)
- VCLI_Out(cli, "default");
- else
- VCLI_Out(cli, "%s", waiter->name);
-
- VCLI_Out(cli, " (");
- for (i = 0; vca_waiters[i] != NULL; i++)
- VCLI_Out(cli, "%s%s", i == 0 ? "" : ", ",
- vca_waiters[i]->name);
- VCLI_Out(cli, ")");
- return;
- }
- if (!strcmp(arg, "default")) {
- waiter = NULL;
- return;
- }
- for (i = 0; vca_waiters[i]; i++) {
- if (!strcmp(arg, vca_waiters[i]->name)) {
- waiter = vca_waiters[i];
- return;
- }
- }
- VCLI_Out(cli, "Unknown waiter");
- VCLI_SetResult(cli, CLIS_PARAM);
-}
-
-void
-WAIT_Init(void)
-{
-
- if (waiter == NULL)
- waiter = vca_waiters[0];
-
- AN(waiter);
- AN(waiter->name);
- AN(waiter->init);
- AN(waiter->pass);
-}
More information about the varnish-commit
mailing list