From: phk Date: Tue, 13 Jun 2006 13:10:09 +0000 (+0000) Subject: Clone the stevedore before calling its init function and be more precise X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3df69b68bb73e1092c7168d46ee184291ecc0ac1;p=varnish Clone the stevedore before calling its init function and be more precise about any optional arguments. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@174 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index de317eb8..a38766d7 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -309,22 +309,27 @@ cmp_storage(struct stevedore *s, const char *p, const char *q) static void setup_storage(const char *sflag) { - const char *p; + const char *p, *q; + struct stevedore *stp; - p = strchr(sflag, ','); + q = p = strchr(sflag, ','); if (p == NULL) - p = strchr(sflag, '\0'); + q = p = strchr(sflag, '\0'); + else + q++; if (!cmp_storage(&sma_stevedore, sflag, p)) { - heritage.stevedore = &sma_stevedore; + stp = &sma_stevedore; } else if (!cmp_storage(&smf_stevedore, sflag, p)) { - heritage.stevedore = &smf_stevedore; + stp = &smf_stevedore; } else { fprintf(stderr, "Unknown storage method \"%*.*s\"\n", p - sflag, p - sflag, sflag); exit (2); } - if (heritage.stevedore->init != NULL) - heritage.stevedore->init(heritage.stevedore, p); + heritage.stevedore = malloc(sizeof *heritage.stevedore); + *heritage.stevedore = *stp; + if (stp->init != NULL) + stp->init(heritage.stevedore, q); } /*--------------------------------------------------------------------*/