]> err.no Git - varnish/commitdiff
Additional style cleanup; remove stevedore list from heritage; revert
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 20 Jul 2007 09:44:21 +0000 (09:44 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 20 Jul 2007 09:44:21 +0000 (09:44 +0000)
locking, which introduces a choke point.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1732 d4fa192b-c00b-0410-8231-f00ffab90ce4

12 files changed:
varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_fetch.c
varnish-cache/bin/varnishd/cache_hash.c
varnish-cache/bin/varnishd/cache_main.c
varnish-cache/bin/varnishd/cache_response.c
varnish-cache/bin/varnishd/cache_synthetic.c
varnish-cache/bin/varnishd/heritage.h
varnish-cache/bin/varnishd/mgt.h
varnish-cache/bin/varnishd/stevedore.c
varnish-cache/bin/varnishd/storage_file.c
varnish-cache/bin/varnishd/storage_malloc.c
varnish-cache/bin/varnishd/varnishd.c

index 8f180007599a7d1a92b907e4fb259b8050eeb538..84df1e2cfd046a9eda7716ce288529a5539ca1f8 100644 (file)
@@ -214,8 +214,6 @@ struct storage {
        off_t                   where;
 };
 
-#include "stevedore.h"
-
 /* -------------------------------------------------------------------*/
 
 struct object {
index 2f2021f521b67ba7520635c3ddb9278303e0da5f..3a17701f824b3a1fb06add212a8af833b38a5c0d 100644 (file)
@@ -44,6 +44,7 @@
 #include "shmlog.h"
 #include "cache.h"
 #include "heritage.h"
+#include "stevedore.h"
 
 /*--------------------------------------------------------------------*/
 
index f0be07f8a2ed6643e822c45ea5a3806159b570b5..502f10f52f02bef0edc1b529cf53f5b521ff59c3 100644 (file)
@@ -59,8 +59,9 @@
 #include <fcntl.h>
 
 #include "shmlog.h"
-#include "heritage.h"
 #include "cache.h"
+#include "heritage.h"
+#include "stevedore.h"
 
 static struct hash_slinger      *hash;
 
index 4f47b8e11646c0f56aba15d7d32f37536659808f..327a74fd7ceed7b7c14bb993870dc19867390577 100644 (file)
 #include <stdlib.h>
 #include <signal.h>
 
-#include "heritage.h"
 #include "shmlog.h"
 #include "cache.h"
-
+#include "heritage.h"
+#include "stevedore.h"
 
 /*--------------------------------------------------------------------
  * XXX: Think more about which order we start things
@@ -46,6 +46,7 @@
 void
 child_main(void)
 {
+
        setbuf(stdout, NULL);
        setbuf(stderr, NULL);
        printf("Child starts\n");
@@ -65,7 +66,7 @@ child_main(void)
        BAN_Init();
 
        STV_open();
-       
+
        printf("Ready\n");
        VSL_stats->start_time = (time_t)TIM_real();
 
index e765be181a5f7bfc3634f1d6fc4cb90cc540549e..e88d2138250fb99348bda044192808a225040cbc 100644 (file)
@@ -151,7 +151,6 @@ RES_WriteObj(struct sess *sp)
                TAILQ_FOREACH(st, &sp->obj->store, list) {
                        CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
                        CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
-                       AN(st->stevedore);
                        u += st->len;
                        sp->wrk->acct.bodybytes += st->len;
 #ifdef HAVE_SENDFILE
index 28ded2151254ccaae7e36d07bb7389a8d0ee1ca4..390895ea46a9968e7ab97ed8263da4ea4eef7f9a 100644 (file)
@@ -34,8 +34,9 @@
 #include <stdlib.h>
 
 #include "shmlog.h"
-#include "heritage.h"
 #include "cache.h"
+#include "heritage.h"
+#include "stevedore.h"
 
 /*
  * Synthesize an error page.  This assumes the session already has an
@@ -87,7 +88,6 @@ SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl)
        /* allocate space for body */
        /* XXX what if the object already has a body? */
        st = STV_alloc(1024);
-       XXXAN(st->stevedore);
        TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
 
        /* generate body */
index 249224a49dd003ba30558a233e2c19b39d5c910e..a30e607eeebffe4872bd1311f9f12e3e8167b479 100644 (file)
@@ -41,7 +41,6 @@ struct listen_sock {
 };
 
 TAILQ_HEAD(listen_sock_head, listen_sock);
-TAILQ_HEAD(stevedore_head, stevedore);
 
 struct heritage {
 
@@ -59,10 +58,6 @@ struct heritage {
        int                             vsl_fd;
        unsigned                        vsl_size;
 
-       /* Storage method */
-       struct stevedore_head           stevedore_h;
-       pthread_mutex_t stevedore_lock;
-
        /* Hash method */
        struct hash_slinger             *hash;
 
index 20c820b402ecbc3b3f709a1b14e73d6134a0595a..afd8fb4c1aa0856efe909e0a26e6b748c01919e6 100644 (file)
@@ -61,13 +61,7 @@ void mgt_vcc_init(void);
 int mgt_vcc_default(const char *bflag, const char *fflag, int f_fd, int Cflag);
 int mgt_push_vcls_and_start(unsigned *status, char **p);
 
-#include "stevedore.h"
-
-extern struct stevedore sma_stevedore;
-extern struct stevedore smf_stevedore;
-
 #include "hash_slinger.h"
 
 extern struct hash_slinger hsl_slinger;
 extern struct hash_slinger hcl_slinger;
-
index 9e597b388409e9c0689fc522b202afe1b8834655..b018e3f11ce31dac0b76b5b4431ff15d1d26b8ec 100644 (file)
 
 #include "cache.h"
 #include "heritage.h"
+#include "stevedore.h"
 
 extern struct stevedore sma_stevedore;
 extern struct stevedore smf_stevedore;
 
+static TAILQ_HEAD(stevedore_head, stevedore) stevedores;
 
 struct storage *
 STV_alloc(size_t size)
 {
        struct storage *st;
        struct stevedore *stv, *stv_first;
-       struct stevedore_head *stevedore_h = &heritage.stevedore_h;
 
        /* Simple round robin selecting of a stevedore. */
-       pthread_mutex_lock(&heritage.stevedore_lock);
-       stv_first = TAILQ_FIRST(stevedore_h);
+       stv_first = TAILQ_FIRST(&stevedores);
        stv = stv_first;
        do {
                AN(stv->alloc);
                st = stv->alloc(stv, size);
-               TAILQ_REMOVE(stevedore_h, stv, stevedore_list);
-               TAILQ_INSERT_TAIL(stevedore_h, stv, stevedore_list);
-               if (st != NULL) {
-                       pthread_mutex_unlock(&heritage.stevedore_lock);
+               TAILQ_REMOVE(&stevedores, stv, stevedore_list);
+               TAILQ_INSERT_TAIL(&stevedores, stv, stevedore_list);
+               if (st != NULL)
                        return (st);
-               }
-       } while ((stv = TAILQ_FIRST(stevedore_h)) != stv_first);
-       
+       } while ((stv = TAILQ_FIRST(&stevedores)) != stv_first);
+
        /* No stevedore with enough space is found. Make room in the first
         * one in the list, and move it to the end. Ensuring the round-robin.
         */
-       stv = TAILQ_FIRST(stevedore_h);
-       TAILQ_REMOVE(stevedore_h, stv, stevedore_list);
-       TAILQ_INSERT_TAIL(stevedore_h, stv, stevedore_list);
-       pthread_mutex_unlock(&heritage.stevedore_lock);
-       
+       stv = TAILQ_FIRST(&stevedores);
+       TAILQ_REMOVE(&stevedores, stv, stevedore_list);
+       TAILQ_INSERT_TAIL(&stevedores, stv, stevedore_list);
+
        do {
                if ((st = stv->alloc(stv, size)) == NULL)
                        AN(LRU_DiscardOne());
        } while (st == NULL);
-       
+
        return (st);
 }
 
@@ -118,9 +115,9 @@ STV_add(const char *spec)
                q = p + 1;
        xxxassert(p != NULL);
        xxxassert(q != NULL);
-       
+
        stp = malloc(sizeof *stp);
-       
+
        if (!cmp_storage(&sma_stevedore, spec, p)) {
                *stp = sma_stevedore;
        } else if (!cmp_storage(&smf_stevedore, spec, p)) {
@@ -130,21 +127,18 @@ STV_add(const char *spec)
                    (int)(p - spec), spec);
                exit (2);
        }
-       TAILQ_INSERT_HEAD(&heritage.stevedore_h, stp, stevedore_list);
+       TAILQ_INSERT_HEAD(&stevedores, stp, stevedore_list);
        if (stp->init != NULL)
                stp->init(stp, q);
 }
 
-void 
+void
 STV_open(void)
 {
-       struct stevedore_head *stevedore_h;
        struct stevedore *st;
-       
-       stevedore_h = &heritage.stevedore_h;
-       TAILQ_FOREACH(st, stevedore_h, stevedore_list) {
+
+       TAILQ_FOREACH(st, &stevedores, stevedore_list) {
                if (st->open != NULL)
                        st->open(st);
        }
-       pthread_mutex_init(&heritage.stevedore_lock, NULL);
 }
index 8b8da7da42759faf93463cdec0eb2036e72d4e1b..344a5e4ed4936a781b5baab96561caa2a2536ad7 100644 (file)
 #ifndef HAVE_ASPRINTF
 #include "compat/asprintf.h"
 #endif
+
 #include "shmlog.h"
 #include "cache.h"
+#include "stevedore.h"
 
 #ifndef MAP_NOCORE
 #define MAP_NOCORE 0 /* XXX Linux */
index e7a2fbb4de9957ccb315592220024448564f69cb..6f62fd4f675e4258122c22beb225752834157ac4 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "shmlog.h"
 #include "cache.h"
+#include "stevedore.h"
 
 struct sma {
        struct storage          s;
index f9fc09ed3f1d64539bed33d3c703c38e9de6ff35..343478a71cc408e28340ccb7d76494e138b5d8e7 100644 (file)
 #include "cli_priv.h"
 #include "cli_common.h"
 
-#include "mgt.h"
-#include "heritage.h"
 #include "shmlog.h"
+#include "heritage.h"
+#include "mgt.h"
+#include "stevedore.h"
 
 /* INFTIM indicates an infinite timeout for poll(2) */
 #ifndef INFTIM
@@ -392,8 +393,7 @@ main(int argc, char *argv[])
        cli[0].result = CLIS_OK;
 
        TAILQ_INIT(&heritage.socks);
-       TAILQ_INIT(&heritage.stevedore_h);
-       
+
        mgt_vcc_init();
 
        MCF_ParamInit(cli);
@@ -536,7 +536,7 @@ main(int argc, char *argv[])
 
        if (!s_arg_given)
                STV_add(s_arg);
-       
+
        setup_hash(h_arg);
 
        VSL_MgtInit(SHMLOG_FILENAME, 8*1024*1024);