]> err.no Git - varnish/commitdiff
Clone the malloc stevedore to the file stevedore
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 13 Jun 2006 08:02:59 +0000 (08:02 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 13 Jun 2006 08:02:59 +0000 (08:02 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@172 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/Makefile.am
varnish-cache/bin/varnishd/mgt.h
varnish-cache/bin/varnishd/storage_file.c [new file with mode: 0644]
varnish-cache/bin/varnishd/varnishd.c

index ef5b227581a5baa753a38873a373278f56a6ee3e..8a23a035ed4338f436566711c2d310bb38cb1b68 100644 (file)
@@ -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
index 9cc269e6601130f2539488bf2b948c990f136dbf..89c90d52558c3dd98b2b38c4ec9db30c3b60a484 100644 (file)
@@ -17,3 +17,4 @@ int open_tcp(const char *port);
 #include "_stevedore.h"
 
 extern struct stevedore sma_stevedore;
+extern struct stevedore smf_stevedore;
diff --git a/varnish-cache/bin/varnishd/storage_file.c b/varnish-cache/bin/varnishd/storage_file.c
new file mode 100644 (file)
index 0000000..3e5c960
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * $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
+};
index 3d0c2e56059bde3530917820e13f6763196635ff..de317eb80ad0ccae9fb5125a50237a279b53207f 100644 (file)
@@ -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);