Commit 21e4ad19 authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

Additional style cleanup; remove stevedore list from heritage; revert

locking, which introduces a choke point.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1732 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e32d4850
......@@ -214,8 +214,6 @@ struct storage {
off_t where;
};
#include "stevedore.h"
/* -------------------------------------------------------------------*/
struct object {
......
......@@ -44,6 +44,7 @@
#include "shmlog.h"
#include "cache.h"
#include "heritage.h"
#include "stevedore.h"
/*--------------------------------------------------------------------*/
......
......@@ -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;
......
......@@ -34,10 +34,10 @@
#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();
......
......@@ -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
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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;
......@@ -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 @@ 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);
}
......@@ -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 */
......
......@@ -37,6 +37,7 @@
#include "shmlog.h"
#include "cache.h"
#include "stevedore.h"
struct sma {
struct storage s;
......
......@@ -61,9 +61,10 @@
#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);
......
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