#1625: if(req.backend_hint == b1) compiles, but does nothing
-------------------------+--------------------
Reporter: huguesalary | Type: defect
Status: new | Priority: normal
Milestone: | Component: build
Version: 4.0.2 | Severity: normal
Keywords: |
-------------------------+--------------------
In vcl_deliver, I'm currently trying to detect which backend a request was
sent to.
I originally tried to detect which **director** a request was assigned to,
but I found this bug report: https://www.varnish-
cache.org/trac/ticket/1502 and realized that doing {{{ if (
req.backend_hint == name-of-director ) { } }}} is not possible, and **will
never be**.
However, the following code snippet compiles correctly, but does not
actually work:
{{{
backend b0 {
.host = "127.0.0.1";
.port = "80";
}
backend b1 {
.host = "127.0.0.1";
.port = "80";
}
sub vcl_init {
new a = directors.round_robin();
a.add_backend(b0);
new b = directors.round_robin();
b.add_backend(b1);
}
sub vcl_recv {
if(std.random(1,100) <= 50) {
set req.backend_hint = a.backend();
} else {
set req.backend_hint = b.backend();
}
}
sub vcl_deliver {
if(req.backend_hint == b1)
{
set resp.http.Test = "something;
} else {
set resp.http.Test = "something else";
}
}
}}}
The {{{ if }}} condition in //vcl_deliver// always fails and executes the
{{{ else }}}. My guess is that my code is not valid (and will never be),
however, if that is the case, I'd expect it to not compile.
--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1625>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator
_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
-------------------------+--------------------
Reporter: huguesalary | Type: defect
Status: new | Priority: normal
Milestone: | Component: build
Version: 4.0.2 | Severity: normal
Keywords: |
-------------------------+--------------------
In vcl_deliver, I'm currently trying to detect which backend a request was
sent to.
I originally tried to detect which **director** a request was assigned to,
but I found this bug report: https://www.varnish-
cache.org/trac/ticket/1502 and realized that doing {{{ if (
req.backend_hint == name-of-director ) { } }}} is not possible, and **will
never be**.
However, the following code snippet compiles correctly, but does not
actually work:
{{{
backend b0 {
.host = "127.0.0.1";
.port = "80";
}
backend b1 {
.host = "127.0.0.1";
.port = "80";
}
sub vcl_init {
new a = directors.round_robin();
a.add_backend(b0);
new b = directors.round_robin();
b.add_backend(b1);
}
sub vcl_recv {
if(std.random(1,100) <= 50) {
set req.backend_hint = a.backend();
} else {
set req.backend_hint = b.backend();
}
}
sub vcl_deliver {
if(req.backend_hint == b1)
{
set resp.http.Test = "something;
} else {
set resp.http.Test = "something else";
}
}
}}}
The {{{ if }}} condition in //vcl_deliver// always fails and executes the
{{{ else }}}. My guess is that my code is not valid (and will never be),
however, if that is the case, I'd expect it to not compile.
--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1625>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator
_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs