Adding a new feature to Update Current Backend in VCL

Joe Chen joec1502 at gmail.com
Fri Jul 30 23:20:58 CEST 2010


Hi,

I have a question about modifying and adding some C code to update a current
backend structure with new hostname and port number.

Background:

I am trying to add a feature of using VCL to update the current Backend with
the new host and port returned from a fetch status 302.  My VCL section
looks like this:

sub vcl_fetch {
    if (beresp.status == 302) {
        set req.url = beresp.http.ocation;
        set req.backend.hostport = beresp.http.location;  # new syntac
introduced here
        restart;
    }
}


My added Function:

After adding an entry in the TCL file, and adding a function
VRT_l_req.backend_hostport(), now my modified Varnish can parse the newly
introduced syntax line and call the right function.  Inside the function, I
was able to extract the new hostname and port number.


My Question:

What's the best way to do the coding so the current Backend data structure
has the new hostname and port number, and the subsequent  opening socket
will connect to the new host?

I believe that inside the new function, the session pointer is supplied and
then I can get access to a director through sp->director.  and from there I
can get access to the current backend data structure.

Any help would be appreciated,

--Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20100730/51223db7/attachment-0003.html>


More information about the varnish-dev mailing list