we actually need to get a filedescriptor to the backend.
This also makes it evident for vcl_pass{}, vcl_pipe{} and vcl_miss{}
if the client sent a Host: header or not. Previously these functions
saw the default Host: header.
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3118
d4fa192b-c00b-0410-8231-
f00ffab90ce4
/* cache_backend.c */
-struct vbe_conn *VBE_GetFd(const struct sess *sp);
+struct vbe_conn *VBE_GetFd(struct sess *sp);
void VBE_ClosedFd(struct worker *w, struct vbe_conn *vc);
void VBE_RecycleFd(struct worker *w, struct vbe_conn *vc);
struct bereq * VBE_new_bereq(void);
/*--------------------------------------------------------------------*/
struct vbe_conn *
-VBE_GetFd(const struct sess *sp)
+VBE_GetFd(struct sess *sp)
{
struct backend *bp;
struct vbe_conn *vc;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+
+ VBE_SelectBackend(sp);
bp = sp->backend;
+ CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
/* first look for vbe_conn's we can recycle */
while (1) {
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
- VBE_SelectBackend(sp);
http_FilterHeader(sp, HTTPH_R_FETCH);
VCL_miss_method(sp);
switch(sp->handling) {
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
AZ(sp->obj);
- VBE_SelectBackend(sp);
http_FilterHeader(sp, HTTPH_R_PASS);
VCL_pass_method(sp);
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
sp->wrk->acct.pipe++;
- VBE_SelectBackend(sp);
http_FilterHeader(sp, HTTPH_R_PIPE);
VCL_pipe_method(sp);
vc = VBE_GetFd(sp);
if (vc == NULL)
return (__LINE__);
+
+ /*
+ * Now that we know our backend, we can set a default Host:
+ * header if one is necessary.
+ * XXX: This possibly ought to go into the default VCL
+ */
+ if (!http_GetHdr(hp, H_Host, &b))
+ VBE_AddHostHeader(sp);
+
TCP_blocking(vc->fd); /* XXX: we should timeout instead */
WRK_Reset(w, &vc->fd);
http_Write(w, hp, 0); /* XXX: stats ? */
{
struct bereq *bereq;
struct http *hp;
- char *b;
bereq = VBE_new_bereq();
AN(bereq);
"X-Forwarded-For: %s", sp->addr);
sp->bereq = bereq;
-
- /* XXX: This possibly ought to go into the default VCL */
- if (!http_GetHdr(hp, H_Host, &b))
- VBE_AddHostHeader(sp);
}
/*--------------------------------------------------------------------