r2775 - trunk/varnish-cache/bin/varnishtest

phk at projects.linpro.no phk at projects.linpro.no
Sun Jun 22 23:40:22 CEST 2008


Author: phk
Date: 2008-06-22 23:40:21 +0200 (Sun, 22 Jun 2008)
New Revision: 2775

Modified:
   trunk/varnish-cache/bin/varnishtest/vtc_log.c
   trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
Log:
A better solution than mutexes: give the thread that listens to
varnish debugging output a separate log handle.

(The point here is to maximize the amount of concurrency we can
simulate.  Down the road, the logging may become pre thread with
a final sorting pass to get all the messages correctly interleaved.)



Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_log.c	2008-06-22 21:34:50 UTC (rev 2774)
+++ trunk/varnish-cache/bin/varnishtest/vtc_log.c	2008-06-22 21:40:21 UTC (rev 2775)
@@ -49,7 +49,6 @@
 #define VTCLOG_MAGIC	0x82731202
 	const char	*id;
 	struct vsb	*vsb;
-	pthread_mutex_t	mtx;
 };
 
 struct vtclog *
@@ -61,7 +60,6 @@
 	AN(vl);	
 	vl->id = id;
 	vl->vsb = vsb_newauto();
-	AZ(pthread_mutex_init(&vl->mtx, NULL));
 	return (vl);
 }
 
@@ -82,7 +80,6 @@
 	assert(lvl < NLEAD);
 	if (lvl > vtc_verbosity)
 		return;
-	AZ(pthread_mutex_lock(&vl->mtx));
 	vsb_printf(vl->vsb, "%s %-4s ", lead[lvl], vl->id);
 	va_list ap;
 	va_start(ap, fmt);
@@ -93,7 +90,6 @@
 	AZ(vsb_overflowed(vl->vsb));
 	(void)fputs(vsb_data(vl->vsb), stdout);
 	vsb_clear(vl->vsb);
-	AZ(pthread_mutex_unlock(&vl->mtx));
 	if (lvl == 0)
 		exit (1);
 }
@@ -112,7 +108,6 @@
 		return;
 	if (pfx == NULL)
 		pfx = "";
-	AZ(pthread_mutex_lock(&vl->mtx));
 	if (str == NULL) 
 		vsb_printf(vl->vsb, "%s %-4s %s(null)\n",
 		    lead[lvl], vl->id, pfx);
@@ -141,7 +136,6 @@
 	AZ(vsb_overflowed(vl->vsb));
 	(void)fputs(vsb_data(vl->vsb), stdout);
 	vsb_clear(vl->vsb);
-	AZ(pthread_mutex_unlock(&vl->mtx));
 	if (lvl == 0)
 		exit (1);
 }

Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c	2008-06-22 21:34:50 UTC (rev 2774)
+++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c	2008-06-22 21:40:21 UTC (rev 2775)
@@ -57,6 +57,7 @@
 #define VARNISH_MAGIC		0x208cd8e3
 	char			*name;
 	struct vtclog		*vl;
+	struct vtclog		*vl1;
 	VTAILQ_ENTRY(varnish)	list;
 
 	const char		*args;
@@ -92,8 +93,8 @@
 	assert(i == 1);
 	i = cli_readres(v->cli_fd, &retval, &r, 1000);
 	assert(i == 0);
-	vtc_log(v->vl, 3, "CLI %u <%s>", retval, cmd);
 	vtc_dump(v->vl, 4, "CLI RX", r);
+	vtc_log(v->vl, 3, "CLI STATUS %u", retval);
 	if (repl != NULL)
 		*repl = r;
 	else
@@ -137,6 +138,8 @@
 	v->name = name;
 	v->vl = vtc_logopen(name);
 	AN(v->vl);
+	v->vl1 = vtc_logopen(name);
+	AN(v->vl1);
 	if (*name != 'v') {
 		vtc_log(v->vl, 0, "Varnish name must start with 'v'");
 		exit (1);
@@ -167,7 +170,7 @@
 		if (i <= 0)
 			break;
 		buf[i] = '\0';
-		vtc_dump(v->vl, 4, "debug", buf);
+		vtc_dump(v->vl1, 4, "debug", buf);
 	}
 	return (NULL);
 }




More information about the varnish-commit mailing list