r140 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Tue Apr 18 09:34:24 CEST 2006
Author: phk
Date: 2006-04-18 09:34:24 +0200 (Tue, 18 Apr 2006)
New Revision: 140
Added:
trunk/varnish-cache/bin/varnishd/storage_malloc.c
Modified:
trunk/varnish-cache/bin/varnishd/Makefile.am
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/hash_simple_list.c
Log:
Add trivial malloc backed storage backend.
Modified: trunk/varnish-cache/bin/varnishd/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishd/Makefile.am 2006-04-12 08:58:54 UTC (rev 139)
+++ trunk/varnish-cache/bin/varnishd/Makefile.am 2006-04-18 07:34:24 UTC (rev 140)
@@ -17,6 +17,7 @@
cli_event.c \
hash_simple_list.c \
mgt_child.c \
+ storage_malloc.c \
tcp.c \
varnishd.c
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2006-04-12 08:58:54 UTC (rev 139)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2006-04-18 07:34:24 UTC (rev 140)
@@ -30,6 +30,28 @@
extern struct hash_slinger hsl_slinger;
+/* Storage -----------------------------------------------------------*/
+
+struct storage {
+ TAILQ_ENTRY(storage) list;
+ void *ptr;
+ unsigned len;
+ void *priv;
+};
+
+typedef void storage_init_f(void);
+typedef struct storage *storage_alloc_f(unsigned size);
+typedef void storage_free_f(struct storage *);
+
+struct stevedore {
+ const char *name;
+ storage_init_f *init;
+ storage_alloc_f *alloc;
+ storage_free_f *free;
+};
+
+extern struct stevedore sma_stevedore;
+
/* Prototypes etc ----------------------------------------------------*/
Property changes on: trunk/varnish-cache/bin/varnishd/hash_simple_list.c
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/varnish-cache/bin/varnishd/storage_malloc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_malloc.c 2006-04-12 08:58:54 UTC (rev 139)
+++ trunk/varnish-cache/bin/varnishd/storage_malloc.c 2006-04-18 07:34:24 UTC (rev 140)
@@ -0,0 +1,53 @@
+/*
+ * $Id$
+ *
+ * Storage method based on malloc(3)
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/queue.h>
+#include <pthread.h>
+
+#include "vcl_lang.h"
+#include "cache.h"
+
+struct sma {
+ struct storage s;
+};
+
+static void
+sma_init(void)
+{
+}
+
+static struct storage *
+sma_alloc(unsigned size)
+{
+ struct sma *sma;
+
+ sma = calloc(sizeof *sma, 1);
+ assert(sma != NULL);
+ sma->s.priv = sma;
+ sma->s.ptr = malloc(size);
+ assert(sma->s.ptr != NULL);
+ sma->s.len = size;
+ return (&sma->s);
+}
+
+static void
+sma_free(struct storage *s)
+{
+ struct sma *sma;
+
+ sma = s->priv;
+ free(sma->s.ptr);
+ free(sma);
+}
+
+struct stevedore sma_stevedore = {
+ "Malloc",
+ sma_init,
+ sma_alloc,
+ sma_free
+};
Property changes on: trunk/varnish-cache/bin/varnishd/storage_malloc.c
___________________________________________________________________
Name: svn:keywords
+ Id
More information about the varnish-commit
mailing list