Mailing List Archive

r1732 - trunk/varnish-cache/bin/varnishd
Author: des
Date: 2007-07-20 11:44:21 +0200 (Fri, 20 Jul 2007)
New Revision: 1732

Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/cache_main.c
trunk/varnish-cache/bin/varnishd/cache_response.c
trunk/varnish-cache/bin/varnishd/cache_synthetic.c
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt.h
trunk/varnish-cache/bin/varnishd/stevedore.c
trunk/varnish-cache/bin/varnishd/storage_file.c
trunk/varnish-cache/bin/varnishd/storage_malloc.c
trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Additional style cleanup; remove stevedore list from heritage; revert
locking, which introduces a choke point.


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-07-20 09:19:36 UTC (rev 1731)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-07-20 09:44:21 UTC (rev 1732)
@@ -214,8 +214,6 @@
off_t where;
};

-#include "stevedore.h"
-
/* -------------------------------------------------------------------*/

struct object {

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-07-20 09:19:36 UTC (rev 1731)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-07-20 09:44:21 UTC (rev 1732)
@@ -44,6 +44,7 @@
#include "shmlog.h"
#include "cache.h"
#include "heritage.h"
+#include "stevedore.h"

/*--------------------------------------------------------------------*/


Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-07-20 09:19:36 UTC (rev 1731)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-07-20 09:44:21 UTC (rev 1732)
@@ -59,8 +59,9 @@
#include <fcntl.h>

#include "shmlog.h"
+#include "cache.h"
#include "heritage.h"
-#include "cache.h"
+#include "stevedore.h"

static struct hash_slinger *hash;


Modified: trunk/varnish-cache/bin/varnishd/cache_main.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_main.c 2007-07-20 09:19:36 UTC (rev 1731)
+++ trunk/varnish-cache/bin/varnishd/cache_main.c 2007-07-20 09:44:21 UTC (rev 1732)
@@ -34,11 +34,11 @@
#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 @@
BAN_Init();

STV_open();
-
+
printf("Ready\n");
VSL_stats->start_time = (time_t)TIM_real();


Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2007-07-20 09:19:36 UTC (rev 1731)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2007-07-20 09:44:21 UTC (rev 1732)
@@ -151,7 +151,6 @@
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

Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-07-20 09:19:36 UTC (rev 1731)
+++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-07-20 09:44:21 UTC (rev 1732)
@@ -34,8 +34,9 @@
#include <stdlib.h>

#include "shmlog.h"
+#include "cache.h"
#include "heritage.h"
-#include "cache.h"
+#include "stevedore.h"

/*
* Synthesize an error page. This assumes the session already has an
@@ -87,7 +88,6 @@
/* 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 */

Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2007-07-20 09:19:36 UTC (rev 1731)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2007-07-20 09:44:21 UTC (rev 1732)
@@ -41,7 +41,6 @@
};

TAILQ_HEAD(listen_sock_head, listen_sock);
-TAILQ_HEAD(stevedore_head, stevedore);

struct heritage {

@@ -59,10 +58,6 @@
int vsl_fd;
unsigned vsl_size;

- /* Storage method */
- struct stevedore_head stevedore_h;
- pthread_mutex_t stevedore_lock;
-
/* Hash method */
struct hash_slinger *hash;


Modified: trunk/varnish-cache/bin/varnishd/mgt.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt.h 2007-07-20 09:19:36 UTC (rev 1731)
+++ trunk/varnish-cache/bin/varnishd/mgt.h 2007-07-20 09:44:21 UTC (rev 1732)
@@ -61,13 +61,7 @@
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;
-

Modified: trunk/varnish-cache/bin/varnishd/stevedore.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.c 2007-07-20 09:19:36 UTC (rev 1731)
+++ trunk/varnish-cache/bin/varnishd/stevedore.c 2007-07-20 09:44:21 UTC (rev 1732)
@@ -34,46 +34,43 @@

#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 @@
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 @@
(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);
}

Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c 2007-07-20 09:19:36 UTC (rev 1731)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c 2007-07-20 09:44:21 UTC (rev 1732)
@@ -57,8 +57,10 @@
#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 */

Modified: trunk/varnish-cache/bin/varnishd/storage_malloc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_malloc.c 2007-07-20 09:19:36 UTC (rev 1731)
+++ trunk/varnish-cache/bin/varnishd/storage_malloc.c 2007-07-20 09:44:21 UTC (rev 1732)
@@ -37,6 +37,7 @@

#include "shmlog.h"
#include "cache.h"
+#include "stevedore.h"

struct sma {
struct storage s;

Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c 2007-07-20 09:19:36 UTC (rev 1731)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c 2007-07-20 09:44:21 UTC (rev 1732)
@@ -61,9 +61,10 @@
#include "cli_priv.h"
#include "cli_common.h"

+#include "shmlog.h"
+#include "heritage.h"
#include "mgt.h"
-#include "heritage.h"
-#include "shmlog.h"
+#include "stevedore.h"

/* INFTIM indicates an infinite timeout for poll(2) */
#ifndef INFTIM
@@ -392,8 +393,7 @@
cli[0].result = CLIS_OK;

TAILQ_INIT(&heritage.socks);
- TAILQ_INIT(&heritage.stevedore_h);
-
+
mgt_vcc_init();

MCF_ParamInit(cli);
@@ -536,7 +536,7 @@

if (!s_arg_given)
STV_add(s_arg);
-
+
setup_hash(h_arg);

VSL_MgtInit(SHMLOG_FILENAME, 8*1024*1024);