]> err.no Git - varnish/commitdiff
Add trim method to storage backends so chunked encoding can be
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 16 Jun 2006 10:17:25 +0000 (10:17 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 16 Jun 2006 10:17:25 +0000 (10:17 +0000)
stored efficiently.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@190 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/stevedore.h
varnish-cache/bin/varnishd/storage_file.c
varnish-cache/bin/varnishd/storage_malloc.c

index 084bd926f9476a09012b88a800c96dc7a4cdbf41..12269a94199fcefe038b7c775fcdd81241061cec 100644 (file)
@@ -8,6 +8,7 @@ struct sess;
 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 @@ struct stevedore {
        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;
 
index 3ad62fbec41705d2ff658455b0bdf07527789ebb..060e9daf5bd4e27df7fe4973ed920d3ec1f50f22 100644 (file)
@@ -268,8 +268,6 @@ alloc_smf(struct smf_sc *sc, size_t bytes)
 {
        struct smf *sp, *sp2;
 
-       bytes += (sc->pagesize - 1);
-       bytes &= ~(sc->pagesize - 1);
        TAILQ_FOREACH(sp, &sc->free, status) {
                if (sp->size >= bytes)
                        break;
@@ -454,18 +452,31 @@ static struct storage *
 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);
 }
 
 /*--------------------------------------------------------------------*/
 
+static void
+smf_trim(struct storage *s, size_t size)
+{
+
+       /* XXX: implement */
+}
+
+/*--------------------------------------------------------------------*/
+
 static void
 smf_free(struct storage *s)
 {
@@ -503,6 +514,7 @@ struct stevedore smf_stevedore = {
        smf_init,
        smf_open,
        smf_alloc,
+       smf_trim,
        smf_free,
        smf_send
 };
index 01d732170895832087411b185ccf75a9841fe1f5..3bae30bcd4aafabf9da67716f9a1789a20d253e3 100644 (file)
@@ -27,6 +27,7 @@ sma_alloc(struct stevedore *st __unused, unsigned size)
        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 @@ struct stevedore sma_stevedore = {
        NULL,                   /* init */
        NULL,                   /* open */
        sma_alloc,
+       NULL,                   /* trim */
        sma_free
 };