r172 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Tue Jun 13 10:02:59 CEST 2006


Author: phk
Date: 2006-06-13 10:02:59 +0200 (Tue, 13 Jun 2006)
New Revision: 172

Added:
   trunk/varnish-cache/bin/varnishd/storage_file.c
Modified:
   trunk/varnish-cache/bin/varnishd/Makefile.am
   trunk/varnish-cache/bin/varnishd/mgt.h
   trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Clone the malloc stevedore to the file stevedore


Modified: trunk/varnish-cache/bin/varnishd/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishd/Makefile.am	2006-06-13 07:59:20 UTC (rev 171)
+++ trunk/varnish-cache/bin/varnishd/Makefile.am	2006-06-13 08:02:59 UTC (rev 172)
@@ -18,6 +18,7 @@
 	cli_event.c \
 	hash_simple_list.c \
 	mgt_child.c \
+	storage_file.c \
 	storage_malloc.c \
 	tcp.c \
 	varnishd.c

Modified: trunk/varnish-cache/bin/varnishd/mgt.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt.h	2006-06-13 07:59:20 UTC (rev 171)
+++ trunk/varnish-cache/bin/varnishd/mgt.h	2006-06-13 08:02:59 UTC (rev 172)
@@ -17,3 +17,4 @@
 #include "_stevedore.h"
 
 extern struct stevedore sma_stevedore;
+extern struct stevedore smf_stevedore;

Added: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c	2006-06-13 07:59:20 UTC (rev 171)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c	2006-06-13 08:02:59 UTC (rev 172)
@@ -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
+};

Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c	2006-06-13 07:59:20 UTC (rev 171)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c	2006-06-13 08:02:59 UTC (rev 172)
@@ -316,6 +316,8 @@
 		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);




More information about the varnish-commit mailing list