Commit f5d7facf authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Clone the malloc stevedore to the file stevedore


git-svn-id: http://www.varnish-cache.org/svn/trunk@172 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 5860d8e3
......@@ -18,6 +18,7 @@ varnishd_SOURCES = \
cli_event.c \
hash_simple_list.c \
mgt_child.c \
storage_file.c \
storage_malloc.c \
tcp.c \
varnishd.c
......
......@@ -17,3 +17,4 @@ int open_tcp(const char *port);
#include "_stevedore.h"
extern struct stevedore sma_stevedore;
extern struct stevedore smf_stevedore;
/*
* $Id: storage_malloc.c 170 2006-06-13 07:57:32Z phk $
*
* Storage method based on mmap'ed file
*/
#include <assert.h>
#include <stdlib.h>
#include <sys/queue.h>
#include <pthread.h>
#include "vcl_lang.h"
#include "cache.h"
struct smf {
struct storage s;
};
static struct storage *
smf_alloc(struct stevedore *st __unused, unsigned size)
{
struct smf *smf;
smf = calloc(sizeof *smf, 1);
assert(smf != NULL);
smf->s.priv = smf;
smf->s.ptr = malloc(size);
assert(smf->s.ptr != NULL);
smf->s.len = size;
return (&smf->s);
}
static void
smf_free(struct storage *s)
{
struct smf *smf;
smf = s->priv;
free(smf->s.ptr);
free(smf);
}
struct stevedore smf_stevedore = {
"file",
NULL, /* init */
NULL, /* open */
smf_alloc,
smf_free
};
......@@ -316,6 +316,8 @@ setup_storage(const char *sflag)
p = strchr(sflag, '\0');
if (!cmp_storage(&sma_stevedore, sflag, p)) {
heritage.stevedore = &sma_stevedore;
} else if (!cmp_storage(&smf_stevedore, sflag, p)) {
heritage.stevedore = &smf_stevedore;
} else {
fprintf(stderr, "Unknown storage method \"%*.*s\"\n",
p - sflag, p - sflag, sflag);
......
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