r190 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Fri Jun 16 12:17:25 CEST 2006
Author: phk
Date: 2006-06-16 12:17:25 +0200 (Fri, 16 Jun 2006)
New Revision: 190
Modified:
trunk/varnish-cache/bin/varnishd/stevedore.h
trunk/varnish-cache/bin/varnishd/storage_file.c
trunk/varnish-cache/bin/varnishd/storage_malloc.c
Log:
Add trim method to storage backends so chunked encoding can be
stored efficiently.
Modified: trunk/varnish-cache/bin/varnishd/stevedore.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.h 2006-06-16 10:16:00 UTC (rev 189)
+++ trunk/varnish-cache/bin/varnishd/stevedore.h 2006-06-16 10:17:25 UTC (rev 190)
@@ -8,6 +8,7 @@
typedef void storage_init_f(struct stevedore *, const char *spec);
typedef void storage_open_f(struct stevedore *);
typedef struct storage *storage_alloc_f(struct stevedore *, size_t size);
+typedef void storage_trim_f(struct storage *, size_t size);
typedef void storage_free_f(struct storage *);
typedef void storage_send_f(struct storage *, struct sess *);
@@ -16,6 +17,7 @@
storage_init_f *init; /* called by mgt process */
storage_open_f *open; /* called by cache process */
storage_alloc_f *alloc;
+ storage_trim_f *trim;
storage_free_f *free;
storage_send_f *send;
Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c 2006-06-16 10:16:00 UTC (rev 189)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c 2006-06-16 10:17:25 UTC (rev 190)
@@ -268,8 +268,6 @@
{
struct smf *sp, *sp2;
- bytes += (sc->pagesize - 1);
- bytes &= ~(sc->pagesize - 1);
TAILQ_FOREACH(sp, &sc->free, status) {
if (sp->size >= bytes)
break;
@@ -454,12 +452,16 @@
smf_alloc(struct stevedore *st, unsigned size)
{
struct smf *smf;
+ struct smf_sc *sc = st->priv;
- smf = alloc_smf(st->priv, size);
+ size += (sc->pagesize - 1);
+ size &= ~(sc->pagesize - 1);
+ smf = alloc_smf(sc, size);
assert(smf != NULL);
+ smf->s.space = size;
smf->s.priv = smf;
smf->s.ptr = smf->ptr;
- smf->s.len = size;
+ smf->s.len = 0;
smf->s.stevedore = st;
return (&smf->s);
}
@@ -467,6 +469,15 @@
/*--------------------------------------------------------------------*/
static void
+smf_trim(struct storage *s, size_t size)
+{
+
+ /* XXX: implement */
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
smf_free(struct storage *s)
{
struct smf *smf;
@@ -503,6 +514,7 @@
smf_init,
smf_open,
smf_alloc,
+ smf_trim,
smf_free,
smf_send
};
Modified: trunk/varnish-cache/bin/varnishd/storage_malloc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_malloc.c 2006-06-16 10:16:00 UTC (rev 189)
+++ trunk/varnish-cache/bin/varnishd/storage_malloc.c 2006-06-16 10:17:25 UTC (rev 190)
@@ -27,6 +27,7 @@
sma->s.ptr = malloc(size);
assert(sma->s.ptr != NULL);
sma->s.len = size;
+ sma->s.space = size;
return (&sma->s);
}
@@ -45,5 +46,6 @@
NULL, /* init */
NULL, /* open */
sma_alloc,
+ NULL, /* trim */
sma_free
};
More information about the varnish-commit
mailing list