r2774 - trunk/varnish-cache/bin/varnishtest

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


Author: phk
Date: 2008-06-22 23:34:50 +0200 (Sun, 22 Jun 2008)
New Revision: 2774

Modified:
   trunk/varnish-cache/bin/varnishtest/vtc_log.c
Log:
Hold a mutex for each log destination



Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_log.c	2008-06-22 14:20:31 UTC (rev 2773)
+++ trunk/varnish-cache/bin/varnishtest/vtc_log.c	2008-06-22 21:34:50 UTC (rev 2774)
@@ -49,6 +49,7 @@
 #define VTCLOG_MAGIC	0x82731202
 	const char	*id;
 	struct vsb	*vsb;
+	pthread_mutex_t	mtx;
 };
 
 struct vtclog *
@@ -60,6 +61,7 @@
 	AN(vl);	
 	vl->id = id;
 	vl->vsb = vsb_newauto();
+	AZ(pthread_mutex_init(&vl->mtx, NULL));
 	return (vl);
 }
 
@@ -80,6 +82,7 @@
 	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);
@@ -90,6 +93,7 @@
 	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);
 }
@@ -108,6 +112,7 @@
 		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);
@@ -136,6 +141,7 @@
 	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);
 }




More information about the varnish-commit mailing list