Commit 720d0d5a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move waiter selection from param to command-line and pave the road

for them taking parameters.
parent 2c022ed3
......@@ -109,6 +109,7 @@ noinst_HEADERS = \
storage/storage_persistent.h \
waiter/waiter.h \
waiter/waiter_priv.h
waiter/mgt_waiter.h
# Headers for use with vmods
nobase_pkginclude_HEADERS = \
......
......@@ -57,6 +57,7 @@
#include "vrnd.h"
#include "vsha256.h"
#include "vtim.h"
#include "waiter/mgt_waiter.h"
#include "compat/daemon.h"
......@@ -186,6 +187,18 @@ usage(void)
"Telnet listen address and port");
fprintf(stderr, FMT, "-t", "Default TTL");
fprintf(stderr, FMT, "-V", "version");
fprintf(stderr, FMT, "-W waiter", "Waiter implementation");
#if defined(HAVE_KQUEUE)
fprintf(stderr, FMT, "", " -W kqueue");
#endif
#if defined(HAVE_EPOLL_CTL)
fprintf(stderr, FMT, "", " -W epoll");
#endif
#if defined(HAVE_PORT_CREATE)
fprintf(stderr, FMT, "", " -W ports");
#endif
fprintf(stderr, FMT, "", " -W poll");
#undef FMT
exit(1);
}
......@@ -438,6 +451,7 @@ main(int argc, char * const *argv)
const char *P_arg = NULL;
const char *S_arg = NULL;
const char *s_arg = "malloc,100m";
const char *W_arg = NULL;
int s_arg_given = 0;
const char *T_arg = "localhost:0";
char *p, *vcl = NULL;
......@@ -496,7 +510,7 @@ main(int argc, char * const *argv)
cli_check(cli);
while ((o = getopt(argc, argv,
"a:b:Cdf:Fh:i:j:l:M:n:P:p:r:S:s:T:t:Vx:")) != -1) {
"a:b:Cdf:Fh:i:j:l:M:n:P:p:r:S:s:T:t:VW:x:")) != -1) {
/*
* -j must be the first argument if specified, because
* it (may) affect subsequent argument processing.
......@@ -593,6 +607,9 @@ main(int argc, char * const *argv)
/* XXX: we should print the ident here */
VCS_Message("varnishd");
exit(0);
case 'W':
W_arg = optarg;
break;
case 'x':
if (!strcmp(optarg, "dumprstparam")) {
MCF_DumpRstParam();
......@@ -708,6 +725,8 @@ main(int argc, char * const *argv)
HSH_config(h_arg);
Wait_config(W_arg);
mgt_SHM_Init();
AZ(VSB_finish(vident));
......
......@@ -35,7 +35,6 @@
#include "common/params.h"
#include "mgt/mgt_param.h"
#include "waiter/waiter.h"
#define MEMPOOL_TEXT \
......@@ -370,11 +369,6 @@ struct parspec mgt_parspec[] = {
"more sessions take a detour around the waiter.",
EXPERIMENTAL,
"0.050", "seconds" },
{ "waiter", tweak_waiter, NULL,
NULL, NULL,
"Select the waiter kernel interface.",
WIZARD | MUST_RESTART,
WAITER_DEFAULT, NULL },
{ "ban_dups", tweak_bool, &mgt_param.ban_dups,
NULL, NULL,
"Eliminate older identical bans when new bans are created."
......
......@@ -43,7 +43,6 @@
#include "common/params.h"
#include "mgt/mgt_param.h"
#include "waiter/waiter.h"
#include "vav.h"
#include "vnum.h"
......@@ -380,17 +379,6 @@ tweak_string(struct vsb *vsb, const struct parspec *par, const char *arg)
/*--------------------------------------------------------------------*/
int
tweak_waiter(struct vsb *vsb, const struct parspec *par, const char *arg)
{
/* XXX should have tweak_generic_string */
(void)par;
return (Wait_Argument(vsb, arg));
}
/*--------------------------------------------------------------------*/
int
tweak_poolparam(struct vsb *vsb, const struct parspec *par, const char *arg)
{
......
......@@ -38,6 +38,7 @@
#include "waiter/waiter.h"
#include "waiter/waiter_priv.h"
#include "waiter/mgt_waiter.h"
int
Wait_Enter(const struct waiter *w, struct waited *wp)
......
......@@ -43,6 +43,7 @@
#include "waiter/waiter.h"
#include "waiter/waiter_priv.h"
#include "waiter/mgt_waiter.h"
#include "vtim.h"
#include "vfil.h"
......
......@@ -42,6 +42,7 @@
#include "waiter/waiter.h"
#include "waiter/waiter_priv.h"
#include "waiter/mgt_waiter.h"
#include "vtim.h"
#define NKEV 256
......
......@@ -38,6 +38,7 @@
#include "waiter/waiter.h"
#include "waiter/waiter_priv.h"
#include "waiter/mgt_waiter.h"
#include "vtim.h"
struct vwp {
......
......@@ -45,6 +45,7 @@
#include "waiter/waiter.h"
#include "waiter/waiter_priv.h"
#include "waiter/mgt_waiter.h"
#include "vtim.h"
#define MAX_EVENTS 256
......
......@@ -33,59 +33,35 @@
#include <unistd.h>
#include <string.h>
#include "common/common.h"
#include "mgt/mgt.h"
#include "waiter/mgt_waiter.h"
#include "waiter/waiter.h"
#include "waiter/waiter_priv.h"
static const struct waiter_impl *const waiter_impls[] = {
static const struct choice waiter_choice[] = {
#if defined(HAVE_KQUEUE)
&waiter_kqueue,
{ "kqueue", &waiter_kqueue },
#endif
#if defined(HAVE_EPOLL_CTL)
&waiter_epoll,
{ "epoll", &waiter_epoll },
#endif
#if 0
#if defined(HAVE_PORT_CREATE)
&waiter_ports,
{ "ports", &waiter_ports },
#endif
#endif
&waiter_poll,
NULL,
{ "poll", &waiter_poll },
{ NULL, NULL}
};
struct waiter_impl const *waiter;
int
Wait_Argument(struct vsb *vsb, const char *arg)
void
Wait_config(const char *arg)
{
int i;
ASSERT_MGT();
if (arg == NULL) {
if (waiter == NULL)
VSB_printf(vsb, "default");
else
VSB_printf(vsb, "%s", waiter->name);
VSB_printf(vsb, " (possible values: ");
for (i = 0; waiter_impls[i] != NULL; i++)
VSB_printf(vsb, "%s%s", i == 0 ? "" : ", ",
waiter_impls[i]->name);
VSB_printf(vsb, ")");
return(0);
}
if (!strcmp(arg, WAITER_DEFAULT)) {
waiter = waiter_impls[0];
return(0);
}
for (i = 0; waiter_impls[i]; i++) {
if (!strcmp(arg, waiter_impls[i]->name)) {
waiter = waiter_impls[i];
return(0);
}
}
VSB_printf(vsb, "Unknown waiter");
return (-1);
if (arg != NULL)
waiter = pick(waiter_choice, arg, "waiter");
else
waiter = waiter_choice[0].ptr;
}
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2006-2015 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.
*
* Private interfaces
*/
struct waiter_impl;
/* mgt_waiter.c */
extern struct waiter_impl const * waiter;
#if defined(HAVE_EPOLL_CTL)
extern const struct waiter_impl waiter_epoll;
#endif
#if defined(HAVE_KQUEUE)
extern const struct waiter_impl waiter_kqueue;
#endif
#if defined(HAVE_PORT_CREATE)
extern const struct waiter_impl waiter_ports;
#endif
extern const struct waiter_impl waiter_poll;
void Wait_config(const char *arg);
......@@ -61,6 +61,3 @@ int Wait_Enter(const struct waiter *, struct waited *);
struct waiter *Waiter_New(waiter_handle_f *, volatile double *timeout);
void Waiter_Destroy(struct waiter **);
const char *Waiter_GetName(void);
/* mgt_waiter.c */
int Wait_Argument(struct vsb *vsb, const char *arg);
......@@ -63,20 +63,3 @@ struct waiter_impl {
waiter_inject_f *inject;
size_t size;
};
/* mgt_waiter.c */
extern struct waiter_impl const * waiter;
#if defined(HAVE_EPOLL_CTL)
extern const struct waiter_impl waiter_epoll;
#endif
#if defined(HAVE_KQUEUE)
extern const struct waiter_impl waiter_kqueue;
#endif
#if defined(HAVE_PORT_CREATE)
extern const struct waiter_impl waiter_ports;
#endif
extern const struct waiter_impl waiter_poll;
......@@ -24,8 +24,6 @@ varnish v1 -start
varnish v1 -cliok "help"
varnish v1 -cliok "param.set waiter poll"
varnish v1 -clierr 106 "param.set waiter HASH(0x8839c4c)"
varnish v1 -cliok "param.set cli_limit 128"
......
......@@ -5,7 +5,7 @@ server s1 {
txresp -hdr "Connection: close" -body "012345\n"
} -start
varnish v1 -arg "-p waiter=poll" -vcl+backend {} -start
varnish v1 -arg "-Wpoll" -vcl+backend {} -start
client c1 {
txreq -url "/"
......
......@@ -10,7 +10,7 @@ server s0 {
expect_close
} -dispatch
varnish v1 -arg "-p waiter=poll" -vcl+backend {
varnish v1 -arg "-Wpoll" -vcl+backend {
sub vcl_recv {
return (pass);
}
......
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