r265 - in trunk/varnish-cache: bin/varnishd include
phk at projects.linpro.no
phk at projects.linpro.no
Thu Jun 29 15:04:55 CEST 2006
Author: phk
Date: 2006-06-29 15:04:55 +0200 (Thu, 29 Jun 2006)
New Revision: 265
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_backend.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/cache_pass.c
trunk/varnish-cache/bin/varnishd/cache_pipe.c
trunk/varnish-cache/bin/varnishd/cache_pool.c
trunk/varnish-cache/include/shmlog_tags.h
Log:
Add a unique transaction-ID to each request, and register it in the
shmlog so we can match backend transactions with client transactions.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2006-06-28 21:38:20 UTC (rev 264)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2006-06-29 13:04:55 UTC (rev 265)
@@ -92,6 +92,7 @@
struct sess {
int fd;
+ unsigned xid;
/* formatted ascii client address */
char addr[VCA_ADDRBUFSIZE];
@@ -143,7 +144,7 @@
/* cache_backend.c */
void VBE_Init(void);
-int VBE_GetFd(struct backend *bp, void **ptr);
+int VBE_GetFd(struct backend *bp, void **ptr, unsigned xid);
void VBE_ClosedFd(void *ptr);
void VBE_RecycleFd(void *ptr);
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2006-06-28 21:38:20 UTC (rev 264)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2006-06-29 13:04:55 UTC (rev 265)
@@ -201,7 +201,7 @@
*/
int
-VBE_GetFd(struct backend *bp, void **ptr)
+VBE_GetFd(struct backend *bp, void **ptr, unsigned xid)
{
struct vbe *vp;
struct vbe_conn *vc;
@@ -244,6 +244,7 @@
event_base_set(vbe_evb, &vc->ev);
}
*ptr = vc;
+ VSL(SLT_BackendXID, vc->fd, "%u", xid);
return (vc->fd);
}
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2006-06-28 21:38:20 UTC (rev 264)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2006-06-29 13:04:55 UTC (rev 265)
@@ -245,7 +245,7 @@
time_t t_req, t_resp;
int body;
- fd = VBE_GetFd(sp->backend, &fd_token);
+ fd = VBE_GetFd(sp->backend, &fd_token, sp->xid);
assert(fd != -1);
VSL(SLT_Backend, sp->fd, "%d %s", fd, sp->backend->vcl_name);
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2006-06-28 21:38:20 UTC (rev 264)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2006-06-29 13:04:55 UTC (rev 265)
@@ -335,11 +335,6 @@
}
hp->t = ++p;
-#if 0
-printf("Head:\n%#H\n", hp->s, hp->t - hp->s);
-printf("Tail:\n%#H\n", hp->t, hp->v - hp->t);
-#endif
-
event_del(&hp->ev);
if (hp->callback != NULL)
hp->callback(hp->arg, 1);
Modified: trunk/varnish-cache/bin/varnishd/cache_pass.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pass.c 2006-06-28 21:38:20 UTC (rev 264)
+++ trunk/varnish-cache/bin/varnishd/cache_pass.c 2006-06-29 13:04:55 UTC (rev 265)
@@ -157,7 +157,7 @@
char *b;
int cls;
- fd = VBE_GetFd(sp->backend, &fd_token);
+ fd = VBE_GetFd(sp->backend, &fd_token, sp->xid);
assert(fd != -1);
http_BuildSbuf(fd, 1, w->sb, sp->http);
Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2006-06-28 21:38:20 UTC (rev 264)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2006-06-29 13:04:55 UTC (rev 265)
@@ -48,7 +48,7 @@
void *fd_token;
struct edir e1, e2;
- fd = VBE_GetFd(sp->backend, &fd_token);
+ fd = VBE_GetFd(sp->backend, &fd_token, sp->xid);
assert(fd != -1);
http_BuildSbuf(fd, 0, w->sb, sp->http); /* XXX: 0 ?? */
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2006-06-28 21:38:20 UTC (rev 264)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2006-06-29 13:04:55 UTC (rev 265)
@@ -21,6 +21,7 @@
static TAILQ_HEAD(, sess) shd = TAILQ_HEAD_INITIALIZER(shd);
static pthread_cond_t shdcnd;
+static unsigned xids;
/*--------------------------------------------------------------------*/
@@ -131,6 +132,13 @@
vca_return_session(sp);
return;
}
+
+ /*
+ * No locking necessary, we're serialized in the acceptor thread
+ */
+ sp->xid = xids++;
+ VSL(SLT_XID, sp->fd, "%u", sp->xid);
+
VSL_stats->client_req++;
AZ(pthread_mutex_lock(&sessmtx));
TAILQ_INSERT_TAIL(&shd, sp, list);
@@ -149,4 +157,6 @@
for (i = 0; i < 5; i++)
AZ(pthread_create(&tp, NULL, CacheWorker, NULL));
AZ(pthread_detach(tp));
+ srandomdev();
+ xids = random();
}
Modified: trunk/varnish-cache/include/shmlog_tags.h
===================================================================
--- trunk/varnish-cache/include/shmlog_tags.h 2006-06-28 21:38:20 UTC (rev 264)
+++ trunk/varnish-cache/include/shmlog_tags.h 2006-06-29 13:04:55 UTC (rev 265)
@@ -13,6 +13,7 @@
SLTM(SessionReuse)
SLTM(SessionClose)
SLTM(BackendOpen)
+SLTM(BackendXID)
SLTM(BackendReuse)
SLTM(BackendClose)
SLTM(HttpError)
@@ -32,3 +33,4 @@
SLTM(BldHdr)
SLTM(LostHeader)
SLTM(VCL)
+SLTM(XID)
More information about the varnish-commit
mailing list