Hi,<div><br></div><div>I have a question about modifying and adding some C code to update a current backend structure with new hostname and port number.</div><div><br></div><div>Background:</div><div><br></div><div>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:</div>
<div><br></div><div>sub vcl_fetch {</div><div> if (beresp.status == 302) {</div><div> set req.url = beresp.http.ocation;</div><div> set req.backend.hostport = beresp.http.location; # new syntac introduced here</div>
<div> restart;</div><div> }</div><div>}</div><div><br></div><div><br></div><div>My added Function:</div><div><br></div><div>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.</div>
<div><br></div><div><br></div><div>My Question:</div><div><br></div><div>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?</div>
<div><br></div><div>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.</div>
<div><br></div><div>Any help would be appreciated,</div><div><br></div><div>--Joe</div><div><br></div><div><br></div><div><br></div><div> </div>