/* cache_backend.c */
void VBE_Init(void);
-struct vbe_conn *VBE_GetFd(struct backend *bp, unsigned xid);
+struct vbe_conn *VBE_GetFd(struct sess *sp);
void VBE_ClosedFd(struct vbe_conn *vc, int already);
void VBE_RecycleFd(struct vbe_conn *vc);
void PassBody(struct sess *sp);
/* cache_pipe.c */
-void PipeSession(struct sess *sp);
+int PipeSession(struct sess *sp);
/* cache_pool.c */
void WRK_Init(void);
* new connection.
*/
-struct vbe_conn *
-VBE_GetFd(struct backend *bp, unsigned xid)
+static struct vbe_conn *
+vbe_nextfd(struct sess *sp)
{
struct vbe_conn *vc, *vc2;
struct pollfd pfd;
+ struct backend *bp;
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ bp = sp->backend;
CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
while (1) {
/*
if (vc != NULL ) {
assert(vc->fd >= 0);
VSL_stats->backend_conn++;
- VSL(SLT_BackendXID, vc->fd, "%u", xid);
+ WSL(sp->wrk, SLT_BackendXID, vc->fd, "%u", sp->xid);
AN(vc->backend);
}
return (vc);
}
+/*--------------------------------------------------------------------*/
+
+struct vbe_conn *
+VBE_GetFd(struct sess *sp)
+{
+ struct vbe_conn *vc;
+
+ vc = vbe_nextfd(sp);
+ if (vc != NULL) {
+ WSL(sp->wrk, SLT_Backend, sp->fd, "%d %s", vc->fd,
+ sp->backend->vcl_name);
+ return (vc);
+ }
+ RES_Error(sp, 503, "Backend did not respond.");
+ return (NULL);
+}
+
/* Close a connection ------------------------------------------------*/
void
INCOMPL();
if (sp->handling == VCL_RET_FETCH) {
AZ(sp->vbc);
- FetchHeaders(sp);
+ if (FetchHeaders(sp)) {
+ sp->obj->cacheable = 0;
+ HSH_Unbusy(sp->obj);
+ HSH_Deref(sp->obj);
+ sp->obj = NULL;
+ sp->step = STP_DONE;
+ return (0);
+ }
sp->step = STP_FETCH;
AN(sp->vbc);
return (0);
{
sp->wrk->acct.pipe++;
- PipeSession(sp);
+ (void)PipeSession(sp);
sp->step = STP_DONE;
return (0);
}
sp->obj->xid = sp->xid;
- vc = VBE_GetFd(sp->backend, sp->xid);
+ vc = VBE_GetFd(sp);
if (vc == NULL)
- vc = VBE_GetFd(sp->backend, sp->xid);
- XXXAN(vc);
- WSL(w, SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
+ return (1);
http_ClrHeader(vc->http);
vc->http->logtag = HTTP_Tx;
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
w = sp->wrk;
- vc = VBE_GetFd(sp->backend, sp->xid);
- if (vc == NULL) {
- RES_Error(sp, 503, "Backend did not respond.");
+ vc = VBE_GetFd(sp);
+ if (vc == NULL)
return (1);
- }
- WSL(w, SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
http_CopyReq(w, vc->fd, vc->http, sp->http);
http_FilterHeader(w, vc->fd, vc->http, sp->http, HTTPH_R_PASS);
}
}
-void
+int
PipeSession(struct sess *sp)
{
struct vbe_conn *vc;
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
w = sp->wrk;
- vc = VBE_GetFd(sp->backend, sp->xid);
- if (vc == NULL) {
- RES_Error(sp, 503, "Backend did not respond.");
- return;
- }
- VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
+ vc = VBE_GetFd(sp);
+ if (vc == NULL)
+ return (1);
vc->http->logtag = HTTP_Tx;
http_CopyReq(w, vc->fd, vc->http, sp->http);
vsb_cat(sb,
"Server: Varnish\r\n"
"Connection: close\r\n"
- "content-Type: text/html; charset=iso-8859-1\r\n"
+ "Content-Type: text/html; charset=iso-8859-1\r\n"
"\r\n"
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
"<HTML>\r\n"