/* cache_backend.c */
void VBE_Init(void);
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 VBE_ClosedFd(struct worker *w, struct vbe_conn *vc, int already);
+void VBE_RecycleFd(struct worker *w, struct vbe_conn *vc);
/* cache_ban.c */
void BAN_Init(void);
void PassBody(struct sess *sp);
/* cache_pipe.c */
-int PipeSession(struct sess *sp);
+void PipeSession(struct sess *sp);
/* cache_pool.c */
void WRK_Init(void);
}
static int
-vbe_connect(struct backend *bp)
+vbe_connect(struct sess *sp, struct backend *bp)
{
int s;
char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE];
TCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
TCP_name(ai->ai_addr, ai->ai_addrlen,
abuf2, sizeof abuf2, pbuf2, sizeof pbuf2);
- VSL(SLT_BackendOpen, s, "%s %s %s %s %s",
+ WSL(sp->wrk, SLT_BackendOpen, s, "%s %s %s %s %s",
bp->vcl_name, abuf1, pbuf1, abuf2, pbuf2);
return (s);
}
pfd.revents = 0;
if (!poll(&pfd, 1, 0))
break;
- VBE_ClosedFd(vc, 0);
+ VBE_ClosedFd(sp->wrk, vc, 0);
}
if (vc == NULL) {
/* If not connected yet, do so */
if (vc->fd < 0) {
AZ(vc->backend);
- vc->fd = vbe_connect(bp);
+ vc->fd = vbe_connect(sp, bp);
LOCK(&vbemtx);
if (vc->fd < 0) {
vc->backend = NULL;
/* Close a connection ------------------------------------------------*/
void
-VBE_ClosedFd(struct vbe_conn *vc, int already)
+VBE_ClosedFd(struct worker *w, struct vbe_conn *vc, int already)
{
CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
assert(vc->fd >= 0);
AN(vc->backend);
- VSL(SLT_BackendClose, vc->fd, "%s", vc->backend->vcl_name);
+ WSL(w, SLT_BackendClose, vc->fd, "%s", vc->backend->vcl_name);
if (!already)
AZ(close(vc->fd));
vc->fd = -1;
/* Recycle a connection ----------------------------------------------*/
void
-VBE_RecycleFd(struct vbe_conn *vc)
+VBE_RecycleFd(struct worker *w, struct vbe_conn *vc)
{
CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
assert(vc->fd >= 0);
AN(vc->backend);
VSL_stats->backend_recycle++;
- VSL(SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name);
+ WSL(w, SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name);
LOCK(&vbemtx);
TAILQ_INSERT_HEAD(&vc->backend->connlist, vc, list);
UNLOCK(&vbemtx);
AZ(sp->obj);
AZ(sp->vbc);
- if (sp->fd >= 0 && sp->doclose != NULL)
- vca_close_session(sp, sp->doclose);
sp->backend = NULL;
if (sp->vcl != NULL) {
if (sp->wrk->vcl != NULL)
sp->xid = 0;
sp->t_open = sp->t_end;
SES_Charge(sp);
+ WSL_Flush(sp->wrk);
+ if (sp->fd >= 0 && sp->doclose != NULL)
+ vca_close_session(sp, sp->doclose);
if (sp->fd < 0) {
VSL_stats->sess_closed++;
sp->wrk->idle = sp->t_open.tv_sec;
{
sp->wrk->acct.pipe++;
- (void)PipeSession(sp);
+ PipeSession(sp);
sp->step = STP_DONE;
return (0);
}
static void *
exp_prefetch(void *arg)
{
+ struct worker ww;
struct object *o;
time_t t;
struct sess *sp;
sp = SES_New(NULL, 0);
XXXAN(sp);
+ sp->wrk = &ww;
+ ww.magic = WORKER_MAGIC;
+ ww.wlp = ww.wlog;
+ ww.wle = ww.wlog + sizeof ww.wlog;
+
sleep(10); /* Takes time for VCL to arrive */
VCL_Get(&sp->vcl);
t = time(NULL);
CHECK_OBJ(o, OBJECT_MAGIC);
if (o == NULL || o->ttl > t + expearly) {
UNLOCK(&exp_mtx);
- VCL_Rel(&sp->vcl);
AZ(sleep(1));
- VCL_Get(&sp->vcl);
+ VCL_Refresh(&sp->vcl);
t = time(NULL);
continue;
}
assert(o2->ttl >= o->ttl);
UNLOCK(&exp_mtx);
- VSL(SLT_ExpPick, 0, "%u", o->xid);
+ WSL(&ww, SLT_ExpPick, 0, "%u", o->xid);
sp->obj = o;
VCL_timeout_method(sp);
cls = 1;
if (cls)
- VBE_ClosedFd(vc, 0);
+ VBE_ClosedFd(sp->wrk, vc, 0);
else
- VBE_RecycleFd(vc);
+ VBE_RecycleFd(sp->wrk, vc);
return (0);
}
cls = 1;
if (cls)
- VBE_ClosedFd(vc, 0);
+ VBE_ClosedFd(sp->wrk, vc, 0);
else
- VBE_RecycleFd(vc);
+ VBE_RecycleFd(sp->wrk, vc);
}
}
}
-int
+void
PipeSession(struct sess *sp)
{
struct vbe_conn *vc;
vc = VBE_GetFd(sp);
if (vc == NULL)
- return (1);
+ return;
vc->http->logtag = HTTP_Tx;
http_CopyReq(w, vc->fd, vc->http, sp->http);
if (WRK_Flush(w)) {
vca_close_session(sp, "pipe");
- VBE_ClosedFd(vc, 0);
+ VBE_ClosedFd(sp->wrk, vc, 0);
return;
}
}
vca_close_session(sp, "pipe");
(void)close (vc->fd);
- VBE_ClosedFd(vc, 1);
+ VBE_ClosedFd(sp->wrk, vc, 1);
}
http_ClrHeader(sp->http);
sp->http->logtag = HTTP_Tx;
- http_SetResp(sp->wrk, sp->fd, sp->http, "HTTP/1.1", "304", "Not Modified");
+ http_SetResp(sp->wrk, sp->fd, sp->http,
+ "HTTP/1.1", "304", NULL);
TIM_format(sp->t_req.tv_sec, lm);
http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Date: %s", lm);
http_SetHeader(sp->wrk, sp->fd, sp->http, "Via: 1.1 varnish");
{ \
\
sp->handling = 0; \
- VSL(SLT_VCL_call, sp->fd, "%s", #func); \
+ WSL(sp->wrk, SLT_VCL_call, sp->fd, "%s", #func); \
sp->vcl->func##_func(sp); \
- VSL(SLT_VCL_return, sp->fd, "%s", \
+ WSL(sp->wrk, SLT_VCL_return, sp->fd, "%s", \
vcl_handlingname(sp->handling)); \
assert(sp->handling & bitmap); \
assert(!(sp->handling & ~bitmap)); \
}
/* calculated TTL, Our time, Date, Expires, max-age, age */
- VSL(SLT_TTL, sp->fd, "%u RFC %d %d %d %d %d %d", sp->xid,
+ WSL(sp->wrk, SLT_TTL, sp->fd, "%u RFC %d %d %d %d %d %d", sp->xid,
(int)(ttd - obj->entered), (int)obj->entered, (int)h_date,
(int)h_expires, (int)u1, (int)u2);