From: phk Date: Sun, 22 Feb 2009 16:36:37 +0000 (+0000) Subject: Move the catalogs of storage and hash modules closer to home. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=787b18605f4d58e8d9436e00eb7c06f439a9351b;p=varnish Move the catalogs of storage and hash modules closer to home. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3803 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index 2ac8f667..afd3e2b3 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -549,3 +549,11 @@ HSH_Init(void) if (hash->start != NULL) hash->start(); } + +const struct choice hsh_choice[] = { + { "classic", &hcl_slinger }, + { "simple", &hsl_slinger }, + { "simple_list", &hsl_slinger }, /* backwards compat */ + { "critbit", &hcb_slinger }, + { NULL, NULL } +}; diff --git a/varnish-cache/bin/varnishd/common.h b/varnish-cache/bin/varnishd/common.h index 8b00863a..7c496ca3 100644 --- a/varnish-cache/bin/varnishd/common.h +++ b/varnish-cache/bin/varnishd/common.h @@ -52,3 +52,9 @@ void mgt_child_inherit(int fd, const char *what); fprintf(stderr, "Error: " __VA_ARGS__); \ exit(2); \ } while (0); + +/* A tiny helper for choosing hash/storage modules */ +struct choice { + const char *name; + void *ptr; +}; diff --git a/varnish-cache/bin/varnishd/hash_slinger.h b/varnish-cache/bin/varnishd/hash_slinger.h index 602e3a30..e37297fc 100644 --- a/varnish-cache/bin/varnishd/hash_slinger.h +++ b/varnish-cache/bin/varnishd/hash_slinger.h @@ -103,3 +103,8 @@ extern unsigned save_hash; void HSH_DeleteObjHead(const struct worker *w, struct objhead *oh); void HSH_Deref(const struct worker *w, struct object **o); #endif /* VARNISH_CACHE_CHILD */ + +extern struct hash_slinger hsl_slinger; +extern struct hash_slinger hcl_slinger; +extern struct hash_slinger hcb_slinger; +extern const struct choice hsh_choice[]; diff --git a/varnish-cache/bin/varnishd/mgt.h b/varnish-cache/bin/varnishd/mgt.h index 1f601aaa..245cc01f 100644 --- a/varnish-cache/bin/varnishd/mgt.h +++ b/varnish-cache/bin/varnishd/mgt.h @@ -76,4 +76,3 @@ extern char *mgt_cc_cmd; fprintf(stderr, fmt "\n", __VA_ARGS__); \ syslog(pri, fmt, __VA_ARGS__); \ } while (0) - diff --git a/varnish-cache/bin/varnishd/stevedore.c b/varnish-cache/bin/varnishd/stevedore.c index fa89cf1c..4cf46d06 100644 --- a/varnish-cache/bin/varnishd/stevedore.c +++ b/varnish-cache/bin/varnishd/stevedore.c @@ -124,3 +124,12 @@ STV_open(void) stv->open(stv); } } + +const struct choice STV_choice[] = { + { "file", &smf_stevedore }, + { "malloc", &sma_stevedore }, +#ifdef HAVE_LIBUMEM + { "umem", &smu_stevedore }, +#endif + { NULL, NULL } +}; diff --git a/varnish-cache/bin/varnishd/stevedore.h b/varnish-cache/bin/varnishd/stevedore.h index 212c8796..c1c192d3 100644 --- a/varnish-cache/bin/varnishd/stevedore.h +++ b/varnish-cache/bin/varnishd/stevedore.h @@ -68,3 +68,11 @@ uintmax_t STV_FileSize(int fd, const char *size, unsigned *granularity, const ch /* Synthetic Storage */ void SMS_Init(void); + +extern struct stevedore sma_stevedore; +extern struct stevedore smf_stevedore; +#ifdef HAVE_LIBUMEM +extern struct stevedore smu_stevedore; +#endif + +extern const struct choice STV_choice[]; diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index 8d241147..a0170611 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -82,11 +82,6 @@ unsigned d_flag = 0; /*--------------------------------------------------------------------*/ -struct choice { - const char *name; - void *ptr; -}; - static void * pick(const struct choice *cp, const char *which, const char *kind) { @@ -113,20 +108,6 @@ arg_ul(const char *p) } /*--------------------------------------------------------------------*/ -extern struct stevedore sma_stevedore; -extern struct stevedore smf_stevedore; -#ifdef HAVE_LIBUMEM -extern struct stevedore smu_stevedore; -#endif - -static const struct choice stv_choice[] = { - { "file", &smf_stevedore }, - { "malloc", &sma_stevedore }, -#ifdef HAVE_LIBUMEM - { "umem", &smu_stevedore }, -#endif - { NULL, NULL } -}; static void setup_storage(const char *spec) @@ -147,7 +128,7 @@ setup_storage(const char *spec) for (ac = 0; av[ac + 2] != NULL; ac++) continue; - priv = pick(stv_choice, av[1], "storage"); + priv = pick(STV_choice, av[1], "storage"); AN(priv); STV_add(priv, ac, av + 2); @@ -157,18 +138,6 @@ setup_storage(const char *spec) /*--------------------------------------------------------------------*/ -extern struct hash_slinger hsl_slinger; -extern struct hash_slinger hcl_slinger; -extern struct hash_slinger hcb_slinger; - -static const struct choice hsh_choice[] = { - { "classic", &hcl_slinger }, - { "simple", &hsl_slinger }, - { "simple_list", &hsl_slinger }, /* backwards compat */ - { "critbit", &hcb_slinger }, - { NULL, NULL } -}; - static void setup_hash(const char *h_arg) {