Commit 7b6d5c9d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Get shmlog records into more sensible order.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1058 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent ed77c9eb
...@@ -298,8 +298,8 @@ void VCA_Init(void); ...@@ -298,8 +298,8 @@ void VCA_Init(void);
/* cache_backend.c */ /* cache_backend.c */
void VBE_Init(void); void VBE_Init(void);
struct vbe_conn *VBE_GetFd(struct sess *sp); struct vbe_conn *VBE_GetFd(struct sess *sp);
void VBE_ClosedFd(struct vbe_conn *vc, int already); void VBE_ClosedFd(struct worker *w, struct vbe_conn *vc, int already);
void VBE_RecycleFd(struct vbe_conn *vc); void VBE_RecycleFd(struct worker *w, struct vbe_conn *vc);
/* cache_ban.c */ /* cache_ban.c */
void BAN_Init(void); void BAN_Init(void);
...@@ -367,7 +367,7 @@ int PassSession(struct sess *sp); ...@@ -367,7 +367,7 @@ int PassSession(struct sess *sp);
void PassBody(struct sess *sp); void PassBody(struct sess *sp);
/* cache_pipe.c */ /* cache_pipe.c */
int PipeSession(struct sess *sp); void PipeSession(struct sess *sp);
/* cache_pool.c */ /* cache_pool.c */
void WRK_Init(void); void WRK_Init(void);
......
...@@ -146,7 +146,7 @@ vbe_conn_try(struct backend *bp, struct addrinfo **pai) ...@@ -146,7 +146,7 @@ vbe_conn_try(struct backend *bp, struct addrinfo **pai)
} }
static int static int
vbe_connect(struct backend *bp) vbe_connect(struct sess *sp, struct backend *bp)
{ {
int s; int s;
char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE]; char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE];
...@@ -163,7 +163,7 @@ vbe_connect(struct backend *bp) ...@@ -163,7 +163,7 @@ vbe_connect(struct backend *bp)
TCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1); TCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
TCP_name(ai->ai_addr, ai->ai_addrlen, TCP_name(ai->ai_addr, ai->ai_addrlen,
abuf2, sizeof abuf2, pbuf2, sizeof pbuf2); 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); bp->vcl_name, abuf1, pbuf1, abuf2, pbuf2);
return (s); return (s);
} }
...@@ -214,7 +214,7 @@ vbe_nextfd(struct sess *sp) ...@@ -214,7 +214,7 @@ vbe_nextfd(struct sess *sp)
pfd.revents = 0; pfd.revents = 0;
if (!poll(&pfd, 1, 0)) if (!poll(&pfd, 1, 0))
break; break;
VBE_ClosedFd(vc, 0); VBE_ClosedFd(sp->wrk, vc, 0);
} }
if (vc == NULL) { if (vc == NULL) {
...@@ -230,7 +230,7 @@ vbe_nextfd(struct sess *sp) ...@@ -230,7 +230,7 @@ vbe_nextfd(struct sess *sp)
/* If not connected yet, do so */ /* If not connected yet, do so */
if (vc->fd < 0) { if (vc->fd < 0) {
AZ(vc->backend); AZ(vc->backend);
vc->fd = vbe_connect(bp); vc->fd = vbe_connect(sp, bp);
LOCK(&vbemtx); LOCK(&vbemtx);
if (vc->fd < 0) { if (vc->fd < 0) {
vc->backend = NULL; vc->backend = NULL;
...@@ -274,13 +274,13 @@ VBE_GetFd(struct sess *sp) ...@@ -274,13 +274,13 @@ VBE_GetFd(struct sess *sp)
/* Close a connection ------------------------------------------------*/ /* Close a connection ------------------------------------------------*/
void 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); CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
assert(vc->fd >= 0); assert(vc->fd >= 0);
AN(vc->backend); 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) if (!already)
AZ(close(vc->fd)); AZ(close(vc->fd));
vc->fd = -1; vc->fd = -1;
...@@ -294,14 +294,14 @@ VBE_ClosedFd(struct vbe_conn *vc, int already) ...@@ -294,14 +294,14 @@ VBE_ClosedFd(struct vbe_conn *vc, int already)
/* Recycle a connection ----------------------------------------------*/ /* Recycle a connection ----------------------------------------------*/
void void
VBE_RecycleFd(struct vbe_conn *vc) VBE_RecycleFd(struct worker *w, struct vbe_conn *vc)
{ {
CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC); CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
assert(vc->fd >= 0); assert(vc->fd >= 0);
AN(vc->backend); AN(vc->backend);
VSL_stats->backend_recycle++; 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); LOCK(&vbemtx);
TAILQ_INSERT_HEAD(&vc->backend->connlist, vc, list); TAILQ_INSERT_HEAD(&vc->backend->connlist, vc, list);
UNLOCK(&vbemtx); UNLOCK(&vbemtx);
......
...@@ -126,8 +126,6 @@ cnt_done(struct sess *sp) ...@@ -126,8 +126,6 @@ cnt_done(struct sess *sp)
AZ(sp->obj); AZ(sp->obj);
AZ(sp->vbc); AZ(sp->vbc);
if (sp->fd >= 0 && sp->doclose != NULL)
vca_close_session(sp, sp->doclose);
sp->backend = NULL; sp->backend = NULL;
if (sp->vcl != NULL) { if (sp->vcl != NULL) {
if (sp->wrk->vcl != NULL) if (sp->wrk->vcl != NULL)
...@@ -153,6 +151,9 @@ cnt_done(struct sess *sp) ...@@ -153,6 +151,9 @@ cnt_done(struct sess *sp)
sp->xid = 0; sp->xid = 0;
sp->t_open = sp->t_end; sp->t_open = sp->t_end;
SES_Charge(sp); SES_Charge(sp);
WSL_Flush(sp->wrk);
if (sp->fd >= 0 && sp->doclose != NULL)
vca_close_session(sp, sp->doclose);
if (sp->fd < 0) { if (sp->fd < 0) {
VSL_stats->sess_closed++; VSL_stats->sess_closed++;
sp->wrk->idle = sp->t_open.tv_sec; sp->wrk->idle = sp->t_open.tv_sec;
...@@ -620,7 +621,7 @@ cnt_pipe(struct sess *sp) ...@@ -620,7 +621,7 @@ cnt_pipe(struct sess *sp)
{ {
sp->wrk->acct.pipe++; sp->wrk->acct.pipe++;
(void)PipeSession(sp); PipeSession(sp);
sp->step = STP_DONE; sp->step = STP_DONE;
return (0); return (0);
} }
......
...@@ -103,6 +103,7 @@ exp_hangman(void *arg) ...@@ -103,6 +103,7 @@ exp_hangman(void *arg)
static void * static void *
exp_prefetch(void *arg) exp_prefetch(void *arg)
{ {
struct worker ww;
struct object *o; struct object *o;
time_t t; time_t t;
struct sess *sp; struct sess *sp;
...@@ -112,6 +113,11 @@ exp_prefetch(void *arg) ...@@ -112,6 +113,11 @@ exp_prefetch(void *arg)
sp = SES_New(NULL, 0); sp = SES_New(NULL, 0);
XXXAN(sp); 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 */ sleep(10); /* Takes time for VCL to arrive */
VCL_Get(&sp->vcl); VCL_Get(&sp->vcl);
t = time(NULL); t = time(NULL);
...@@ -122,9 +128,8 @@ exp_prefetch(void *arg) ...@@ -122,9 +128,8 @@ exp_prefetch(void *arg)
CHECK_OBJ(o, OBJECT_MAGIC); CHECK_OBJ(o, OBJECT_MAGIC);
if (o == NULL || o->ttl > t + expearly) { if (o == NULL || o->ttl > t + expearly) {
UNLOCK(&exp_mtx); UNLOCK(&exp_mtx);
VCL_Rel(&sp->vcl);
AZ(sleep(1)); AZ(sleep(1));
VCL_Get(&sp->vcl); VCL_Refresh(&sp->vcl);
t = time(NULL); t = time(NULL);
continue; continue;
} }
...@@ -136,7 +141,7 @@ exp_prefetch(void *arg) ...@@ -136,7 +141,7 @@ exp_prefetch(void *arg)
assert(o2->ttl >= o->ttl); assert(o2->ttl >= o->ttl);
UNLOCK(&exp_mtx); UNLOCK(&exp_mtx);
VSL(SLT_ExpPick, 0, "%u", o->xid); WSL(&ww, SLT_ExpPick, 0, "%u", o->xid);
sp->obj = o; sp->obj = o;
VCL_timeout_method(sp); VCL_timeout_method(sp);
......
...@@ -265,9 +265,9 @@ FetchBody(struct sess *sp) ...@@ -265,9 +265,9 @@ FetchBody(struct sess *sp)
cls = 1; cls = 1;
if (cls) if (cls)
VBE_ClosedFd(vc, 0); VBE_ClosedFd(sp->wrk, vc, 0);
else else
VBE_RecycleFd(vc); VBE_RecycleFd(sp->wrk, vc);
return (0); return (0);
} }
......
...@@ -183,9 +183,9 @@ PassBody(struct sess *sp) ...@@ -183,9 +183,9 @@ PassBody(struct sess *sp)
cls = 1; cls = 1;
if (cls) if (cls)
VBE_ClosedFd(vc, 0); VBE_ClosedFd(sp->wrk, vc, 0);
else else
VBE_RecycleFd(vc); VBE_RecycleFd(sp->wrk, vc);
} }
......
...@@ -40,7 +40,7 @@ rdf(struct pollfd *fds, int idx) ...@@ -40,7 +40,7 @@ rdf(struct pollfd *fds, int idx)
} }
} }
int void
PipeSession(struct sess *sp) PipeSession(struct sess *sp)
{ {
struct vbe_conn *vc; struct vbe_conn *vc;
...@@ -55,7 +55,7 @@ PipeSession(struct sess *sp) ...@@ -55,7 +55,7 @@ PipeSession(struct sess *sp)
vc = VBE_GetFd(sp); vc = VBE_GetFd(sp);
if (vc == NULL) if (vc == NULL)
return (1); return;
vc->http->logtag = HTTP_Tx; vc->http->logtag = HTTP_Tx;
http_CopyReq(w, vc->fd, vc->http, sp->http); http_CopyReq(w, vc->fd, vc->http, sp->http);
...@@ -69,7 +69,7 @@ PipeSession(struct sess *sp) ...@@ -69,7 +69,7 @@ PipeSession(struct sess *sp)
if (WRK_Flush(w)) { if (WRK_Flush(w)) {
vca_close_session(sp, "pipe"); vca_close_session(sp, "pipe");
VBE_ClosedFd(vc, 0); VBE_ClosedFd(sp->wrk, vc, 0);
return; return;
} }
...@@ -94,5 +94,5 @@ PipeSession(struct sess *sp) ...@@ -94,5 +94,5 @@ PipeSession(struct sess *sp)
} }
vca_close_session(sp, "pipe"); vca_close_session(sp, "pipe");
(void)close (vc->fd); (void)close (vc->fd);
VBE_ClosedFd(vc, 1); VBE_ClosedFd(sp->wrk, vc, 1);
} }
...@@ -143,7 +143,8 @@ res_do_304(struct sess *sp) ...@@ -143,7 +143,8 @@ res_do_304(struct sess *sp)
http_ClrHeader(sp->http); http_ClrHeader(sp->http);
sp->http->logtag = HTTP_Tx; 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); TIM_format(sp->t_req.tv_sec, lm);
http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Date: %s", lm); http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Date: %s", lm);
http_SetHeader(sp->wrk, sp->fd, sp->http, "Via: 1.1 varnish"); http_SetHeader(sp->wrk, sp->fd, sp->http, "Via: 1.1 varnish");
......
...@@ -278,9 +278,9 @@ VCL_##func##_method(struct sess *sp) \ ...@@ -278,9 +278,9 @@ VCL_##func##_method(struct sess *sp) \
{ \ { \
\ \
sp->handling = 0; \ 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); \ 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)); \ vcl_handlingname(sp->handling)); \
assert(sp->handling & bitmap); \ assert(sp->handling & bitmap); \
assert(!(sp->handling & ~bitmap)); \ assert(!(sp->handling & ~bitmap)); \
......
...@@ -117,7 +117,7 @@ RFC2616_Ttl(struct sess *sp, struct http *hp, struct object *obj) ...@@ -117,7 +117,7 @@ RFC2616_Ttl(struct sess *sp, struct http *hp, struct object *obj)
} }
/* calculated TTL, Our time, Date, Expires, max-age, age */ /* 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)(ttd - obj->entered), (int)obj->entered, (int)h_date,
(int)h_expires, (int)u1, (int)u2); (int)h_expires, (int)u1, (int)u2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment