Commit 24041bbb authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Pass beresp.storage into stevedore selection as a hint, and pick any

stevedore which matches the name exactly.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5661 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 70ae3864
...@@ -351,7 +351,8 @@ cnt_error(struct sess *sp) ...@@ -351,7 +351,8 @@ cnt_error(struct sess *sp)
HSH_Prealloc(sp); HSH_Prealloc(sp);
sp->wrk->cacheable = 0; sp->wrk->cacheable = 0;
/* XXX: 1024 is a pure guess */ /* XXX: 1024 is a pure guess */
sp->obj = STV_NewObject(sp, 1024, 0, params->http_headers); sp->obj = STV_NewObject(sp, NULL, 1024, 0,
params->http_headers);
sp->obj->xid = sp->xid; sp->obj->xid = sp->xid;
sp->obj->entered = sp->t_req; sp->obj->entered = sp->t_req;
} else { } else {
...@@ -567,7 +568,7 @@ cnt_fetch(struct sess *sp) ...@@ -567,7 +568,7 @@ cnt_fetch(struct sess *sp)
* XXX: also. * XXX: also.
*/ */
sp->obj = STV_NewObject(sp, l, sp->wrk->ttl, nhttp); sp->obj = STV_NewObject(sp, sp->wrk->storage, l, sp->wrk->ttl, nhttp);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
sp->wrk->storage = NULL; sp->wrk->storage = NULL;
......
...@@ -82,10 +82,18 @@ LRU_Alloc(void) ...@@ -82,10 +82,18 @@ LRU_Alloc(void)
*/ */
static struct stevedore * static struct stevedore *
stv_pick_stevedore(void) stv_pick_stevedore(const char *hint)
{ {
struct stevedore *stv; struct stevedore *stv;
if (hint != NULL && *hint != '\0') {
VTAILQ_FOREACH(stv, &stevedores, list) {
if (!strcmp(stv->ident, hint))
return (stv);
}
if (!strcmp(TRANSIENT_NAME, hint))
return (stv_transient);
}
/* pick a stevedore and bump the head along */ /* pick a stevedore and bump the head along */
stv = VTAILQ_NEXT(stv_next, list); stv = VTAILQ_NEXT(stv_next, list);
if (stv == NULL) if (stv == NULL)
...@@ -93,8 +101,6 @@ stv_pick_stevedore(void) ...@@ -93,8 +101,6 @@ stv_pick_stevedore(void)
AN(stv); AN(stv);
AN(stv->name); AN(stv->name);
stv_next = stv; stv_next = stv;
if (stv->transient)
stv = stv_pick_stevedore();
return (stv); return (stv);
} }
...@@ -239,7 +245,8 @@ stv_default_allocobj(struct stevedore *stv, struct sess *sp, unsigned ltot, ...@@ -239,7 +245,8 @@ stv_default_allocobj(struct stevedore *stv, struct sess *sp, unsigned ltot,
*/ */
struct object * struct object *
STV_NewObject(struct sess *sp, unsigned wsl, double ttl, unsigned nhttp) STV_NewObject(struct sess *sp, const char *hint, unsigned wsl, double ttl,
unsigned nhttp)
{ {
struct object *o; struct object *o;
struct stevedore *stv; struct stevedore *stv;
...@@ -264,7 +271,7 @@ STV_NewObject(struct sess *sp, unsigned wsl, double ttl, unsigned nhttp) ...@@ -264,7 +271,7 @@ STV_NewObject(struct sess *sp, unsigned wsl, double ttl, unsigned nhttp)
if (!sp->wrk->cacheable) if (!sp->wrk->cacheable)
stv = stv_transient; stv = stv_transient;
else else
stv = stv_pick_stevedore(); stv = stv_pick_stevedore(hint);
AN(stv->allocobj); AN(stv->allocobj);
o = stv->allocobj(stv, sp, ltot, &soc); o = stv->allocobj(stv, sp, ltot, &soc);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
......
...@@ -79,8 +79,8 @@ struct stevedore { ...@@ -79,8 +79,8 @@ struct stevedore {
struct object *STV_MkObject(struct sess *sp, void *ptr, unsigned ltot, struct object *STV_MkObject(struct sess *sp, void *ptr, unsigned ltot,
const struct stv_objsecrets *soc); const struct stv_objsecrets *soc);
struct object *STV_NewObject(struct sess *sp, unsigned len, double ttl, struct object *STV_NewObject(struct sess *sp, const char *hint, unsigned len,
unsigned nhttp); double ttl, unsigned nhttp);
struct storage *STV_alloc(const struct sess *sp, size_t size); struct storage *STV_alloc(const struct sess *sp, size_t size);
void STV_trim(struct storage *st, size_t size); void STV_trim(struct storage *st, size_t size);
void STV_free(struct storage *st); void STV_free(struct storage *st);
......
...@@ -5,7 +5,9 @@ test "Stevedore variables and BYTES type test" ...@@ -5,7 +5,9 @@ test "Stevedore variables and BYTES type test"
server s1 { server s1 {
rxreq rxreq
txresp txresp -bodylen 4
rxreq
txresp -bodylen 5
} -start } -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
...@@ -14,6 +16,12 @@ varnish v1 -vcl+backend { ...@@ -14,6 +16,12 @@ varnish v1 -vcl+backend {
set beresp.http.foo = set beresp.http.foo =
storage.nowhere.free_space + storage.nowhere.free_space +
1 B + 1 KB + 1 MB + 1GB + 1TB; 1 B + 1 KB + 1 MB + 1GB + 1TB;
if (req.url == "/foo") {
set beresp.storage = "Transient";
}
}
sub vcl_deliver {
set resp.http.bar = storage.Transient.used_space > 0B;
} }
} -start } -start
...@@ -22,4 +30,11 @@ client c1 { ...@@ -22,4 +30,11 @@ client c1 {
rxresp rxresp
expect resp.status == 200 expect resp.status == 200
expect resp.http.foo == 1100586419201.000 expect resp.http.foo == 1100586419201.000
expect resp.http.bar == false
txreq -url /foo
rxresp
expect resp.status == 200
expect resp.http.foo == 1100586419201.000
expect resp.http.bar == true
} -run } -run
...@@ -83,7 +83,11 @@ vcc_Stv_mkvar(struct vcc *tl, const struct token *t, enum var_type fmt) ...@@ -83,7 +83,11 @@ vcc_Stv_mkvar(struct vcc *tl, const struct token *t, enum var_type fmt)
AN(v); AN(v);
v->name = TlDupTok(tl, t); v->name = TlDupTok(tl, t);
v->r_methods = VCL_MET_FETCH; /* XXX ? */ v->r_methods = 0
#define VCL_MET_MAC(l,u,b) | VCL_MET_##u
#include "vcl_returns.h"
#undef VCL_MET_MAC
;
v->fmt = fmt; v->fmt = fmt;
return (v); return (v);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment