r2199 - in branches/1.2: . bin/varnishd

des at projects.linpro.no des at projects.linpro.no
Tue Oct 30 12:03:23 CET 2007


Author: des
Date: 2007-10-30 12:03:22 +0100 (Tue, 30 Oct 2007)
New Revision: 2199

Modified:
   branches/1.2/
   branches/1.2/bin/varnishd/cache.h
   branches/1.2/bin/varnishd/cache_backend.c
   branches/1.2/bin/varnishd/cache_fetch.c
   branches/1.2/bin/varnishd/cache_session.c
   branches/1.2/bin/varnishd/cache_synthetic.c
   branches/1.2/bin/varnishd/cache_ws.c
Log:
Merged revisions 2182-2183 via svnmerge from 
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache

........
  r2182 | phk | 2007-10-29 10:24:16 +0100 (Mon, 29 Oct 2007) | 2 lines
  
  Add compile-time selectable SHMlogging of WS-activity
........
  r2183 | phk | 2007-10-29 10:28:21 +0100 (Mon, 29 Oct 2007) | 2 lines
  
  Give workspaces an identifying string to aid debugging.
........



Property changes on: branches/1.2
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2181,2191-2192
   + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2183,2191-2192

Modified: branches/1.2/bin/varnishd/cache.h
===================================================================
--- branches/1.2/bin/varnishd/cache.h	2007-10-30 11:03:05 UTC (rev 2198)
+++ branches/1.2/bin/varnishd/cache.h	2007-10-30 11:03:22 UTC (rev 2199)
@@ -89,6 +89,7 @@
  */
 
 struct ws {
+	const char		*id;		/* identity */
 	char			*s;		/* (S)tart of buffer */
 	char			*f;		/* (F)ree pointer */
 	char			*r;		/* (R)eserved length */
@@ -575,7 +576,7 @@
 
 /* cache_ws.c */
 
-void WS_Init(struct ws *ws, void *space, unsigned len);
+void WS_Init(struct ws *ws, const char *id, void *space, unsigned len);
 unsigned WS_Reserve(struct ws *ws, unsigned bytes);
 void WS_Release(struct ws *ws, unsigned bytes);
 void WS_ReleaseP(struct ws *ws, char *ptr);

Modified: branches/1.2/bin/varnishd/cache_backend.c
===================================================================
--- branches/1.2/bin/varnishd/cache_backend.c	2007-10-30 11:03:05 UTC (rev 2198)
+++ branches/1.2/bin/varnishd/cache_backend.c	2007-10-30 11:03:22 UTC (rev 2199)
@@ -147,7 +147,7 @@
 		if (bereq == NULL)
 			return (NULL);
 		bereq->magic = BEREQ_MAGIC;
-		WS_Init(bereq->ws, bereq + 1, len);
+		WS_Init(bereq->ws, "bereq", bereq + 1, len);
 	}
 	http_Setup(bereq->http, bereq->ws);
 	return (bereq);

Modified: branches/1.2/bin/varnishd/cache_fetch.c
===================================================================
--- branches/1.2/bin/varnishd/cache_fetch.c	2007-10-30 11:03:05 UTC (rev 2198)
+++ branches/1.2/bin/varnishd/cache_fetch.c	2007-10-30 11:03:22 UTC (rev 2199)
@@ -278,7 +278,7 @@
 
 	/* Set up obj's workspace */
 	st = sp->obj->objstore;
-	WS_Init(sp->obj->ws_o, st->ptr + st->len, st->space - st->len);
+	WS_Init(sp->obj->ws_o, "obj", st->ptr + st->len, st->space - st->len);
 	st->len = st->space;
 	WS_Assert(sp->obj->ws_o);
 	http_Setup(sp->obj->http, sp->obj->ws_o);

Modified: branches/1.2/bin/varnishd/cache_session.c
===================================================================
--- branches/1.2/bin/varnishd/cache_session.c	2007-10-30 11:03:05 UTC (rev 2198)
+++ branches/1.2/bin/varnishd/cache_session.c	2007-10-30 11:03:22 UTC (rev 2199)
@@ -318,7 +318,7 @@
 		sp->sockaddrlen = len;
 	}
 
-	WS_Init(sp->ws, (void *)(sm + 1), sm->workspace);
+	WS_Init(sp->ws, "sess", (void *)(sm + 1), sm->workspace);
 	sp->http = &sm->http[0];
 	sp->http0 = &sm->http[1];
 

Modified: branches/1.2/bin/varnishd/cache_synthetic.c
===================================================================
--- branches/1.2/bin/varnishd/cache_synthetic.c	2007-10-30 11:03:05 UTC (rev 2198)
+++ branches/1.2/bin/varnishd/cache_synthetic.c	2007-10-30 11:03:22 UTC (rev 2199)
@@ -73,7 +73,7 @@
 
 	/* Set up obj's workspace */
 	st = o->objstore;
-	WS_Init(o->ws_o, st->ptr + st->len, st->space - st->len);
+	WS_Init(o->ws_o, "obj", st->ptr + st->len, st->space - st->len);
 	st->len = st->space;
 	WS_Assert(o->ws_o);
 	http_Setup(o->http, o->ws_o);
@@ -126,7 +126,7 @@
 
 	/* allocate space for header */
 
-	WS_Init(h->ws, malloc(1024), 1024);
+	WS_Init(h->ws, "error", malloc(1024), 1024);
 
 	/* generate header */
 	http_ClrHeader(h);

Modified: branches/1.2/bin/varnishd/cache_ws.c
===================================================================
--- branches/1.2/bin/varnishd/cache_ws.c	2007-10-30 11:03:05 UTC (rev 2198)
+++ branches/1.2/bin/varnishd/cache_ws.c	2007-10-30 11:03:22 UTC (rev 2199)
@@ -45,11 +45,22 @@
 #include "cli_priv.h"
 #include "cache.h"
 
+/* Enable this to get detailed logging of WS usage */
+#if 0
+#  define WS_DEBUG(foo)	VSL foo
+#else
+#  define WS_DEBUG(foo)	/* nothing */
+#endif
+
 void
 WS_Assert(const struct ws *ws)
 {
 
 	assert(ws != NULL);
+	WS_DEBUG((SLT_Debug, 0, "WS(%p = (%s, %p %u %u %u)",
+	    ws, ws->id, ws->s, pdiff(ws->s, ws->f),
+	    ws->r == NULL ? 0 : pdiff(ws->f, ws->r),
+	    pdiff(ws->s, ws->e)));
 	assert(ws->s != NULL);
 	assert(ws->e != NULL);
 	assert(ws->s < ws->e);
@@ -62,14 +73,16 @@
 }
 
 void
-WS_Init(struct ws *ws, void *space, unsigned len)
+WS_Init(struct ws *ws, const char *id, void *space, unsigned len)
 {
 
+	WS_DEBUG((SLT_Debug, 0, "WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len));
 	assert(space != NULL);
 	memset(ws, 0, sizeof *ws);
 	ws->s = space;
 	ws->e = ws->s + len;
 	ws->f = ws->s;
+	ws->id = id;
 	WS_Assert(ws);
 }
 
@@ -78,6 +91,7 @@
 {
 
 	WS_Assert(ws);
+	WS_DEBUG((SLT_Debug, 0, "WS_Reset(%p, %p)", ws, p));
 	assert(ws->r == NULL);
 	if (p == NULL)
 		ws->f = ws->s;
@@ -99,6 +113,7 @@
 		return(NULL);
 	r = ws->f;
 	ws->f += bytes;
+	WS_DEBUG((SLT_Debug, 0, "WS_Alloc(%p, %u) = %p", ws, bytes, r));
 	return (r);
 }
 
@@ -112,6 +127,7 @@
 	p = WS_Alloc(ws, l);
 	if (p != NULL)
 		memcpy(p, s, l);
+	WS_DEBUG((SLT_Debug, 0, "WS_Dup(%p, \"%s\") = %p", ws, s, p));
 	return (p);
 }
 
@@ -119,26 +135,33 @@
 WS_Snapshot(struct ws *ws)
 {
 
+	WS_Assert(ws);
 	assert(ws->r == NULL);
+	WS_DEBUG((SLT_Debug, 0, "WS_Snapshot(%p) = %p", ws, ws->f));
 	return (ws->f);
 }
 
 unsigned
 WS_Reserve(struct ws *ws, unsigned bytes)
 {
+	unsigned b2 = bytes;
+
 	WS_Assert(ws);
 	assert(ws->r == NULL);
 	if (bytes == 0)
-		bytes = ws->e - ws->f;
-	xxxassert(ws->f + bytes <= ws->e);
-	ws->r = ws->f + bytes;
-	return (ws->r - ws->f);
+		b2 = ws->e - ws->f;
+	xxxassert(ws->f + b2 <= ws->e);
+	ws->r = ws->f + b2;
+	WS_DEBUG((SLT_Debug, 0, "WS_Reserve(%p, %u/%u) = %u",
+	    ws, b2, bytes, pdiff(ws->f, ws->r)));
+	return (pdiff(ws->f, ws->r));
 }
 
 void
 WS_Release(struct ws *ws, unsigned bytes)
 {
 	WS_Assert(ws);
+	WS_DEBUG((SLT_Debug, 0, "WS_Release(%p, %u)", ws, bytes));
 	assert(ws->r != NULL);
 	assert(ws->f + bytes <= ws->r);
 	ws->f += bytes;
@@ -149,6 +172,7 @@
 WS_ReleaseP(struct ws *ws, char *ptr)
 {
 	WS_Assert(ws);
+	WS_DEBUG((SLT_Debug, 0, "WS_ReleaseP(%p, %p)", ws, ptr));
 	assert(ws->r != NULL);
 	assert(ptr >= ws->f);
 	assert(ptr <= ws->r);




More information about the varnish-commit mailing list