Commit 21e653c3 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Use the hash digest as identification instead of the neutered objhead

pointer, in order to not have dependency between trouble entry and
objhead lifetime.

Fixes	#1091
parent 4d047a90
......@@ -244,7 +244,6 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp)
unsigned i = 0, retval;
unsigned int threshold;
struct backend *backend;
uintptr_t target;
double now;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
......@@ -276,7 +275,6 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp)
return (1);
now = sp->t_req;
target = (uintptr_t)(sp->req->objcore->objhead);
old = NULL;
retval = 1;
......@@ -291,7 +289,7 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp)
break;
}
if (tr->target == target) {
if (!memcmp(tr->digest, sp->req->digest, sizeof tr->digest)) {
retval = 0;
break;
}
......
......@@ -97,7 +97,7 @@ struct director {
struct trouble {
unsigned magic;
#define TROUBLE_MAGIC 0x4211ab21
uintptr_t target;
unsigned char digest[DIGEST_LEN];
double timeout;
VTAILQ_ENTRY(trouble) list;
};
......
......@@ -152,7 +152,7 @@ VRT_l_beresp_saintmode(const struct sess *sp, double a)
ALLOC_OBJ(new, TROUBLE_MAGIC);
AN(new);
new->target = (uintptr_t)(sp->req->objcore->objhead);
memcpy(new->digest, sp->req->digest, sizeof new->digest);
new->timeout = sp->t_req + a;
/* Insert the new item on the list before the first item with a
......
varnishtest "Test fallback director with saint mode"
server s1 {
rxreq
txresp -hdr "Foo: 1"
accept
rxreq
txresp -hdr "Foo: 1"
} -start
server s2 {
rxreq
txresp -hdr "Foo: 2" -bodylen 1
} -start
varnish v1 -vcl+backend {
director f1 fallback {
{ .backend = s1; }
{ .backend = s2; }
}
sub vcl_recv {
set req.backend = f1;
}
sub vcl_fetch {
if(req.restarts < 1) {
set beresp.saintmode = 1h;
return(restart);
}
}
} -start
client c1 {
txreq
rxresp
expect resp.http.foo == "2"
} -run
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