r4501 - trunk/varnish-cache/bin/varnishtest

phk at projects.linpro.no phk at projects.linpro.no
Thu Jan 28 10:33:16 CET 2010


Author: phk
Date: 2010-01-28 10:33:16 +0100 (Thu, 28 Jan 2010)
New Revision: 4501

Modified:
   trunk/varnish-cache/bin/varnishtest/vtc_sema.c
Log:
Seamlessly hand over the per-sema mutex, to avoid silly context-switches



Modified: trunk/varnish-cache/bin/varnishtest/vtc_sema.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_sema.c	2010-01-28 09:32:34 UTC (rev 4500)
+++ trunk/varnish-cache/bin/varnishtest/vtc_sema.c	2010-01-28 09:33:16 UTC (rev 4501)
@@ -93,7 +93,6 @@
 	CHECK_OBJ_NOTNULL(r, SEMA_MAGIC);
 	u = strtoul(av, NULL, 0);
 
-	AZ(pthread_mutex_lock(&r->mtx));
 	if (r->expected == 0)
 		r->expected = u;
 	if (r->expected != u)
@@ -111,7 +110,6 @@
 		    r->name, r->waiters, r->expected);
 		AZ(pthread_cond_wait(&r->cond, &r->mtx));
 	}
-	AZ(pthread_mutex_unlock(&r->mtx));
 }
 
 /**********************************************************************
@@ -148,8 +146,9 @@
 			break;
 	if (r == NULL)
 		r = sema_new(av[0], vl);
+	av++;
+	AZ(pthread_mutex_lock(&r->mtx));
 	AZ(pthread_mutex_unlock(&sema_mtx));
-	av++;
 
 	for (; *av != NULL; av++) {
 		if (!strcmp(*av, "sync")) {
@@ -160,6 +159,7 @@
 		}
 		vtc_log(vl, 0, "Unknown sema argument: %s", *av);
 	}
+	AZ(pthread_mutex_unlock(&r->mtx));
 }
 
 void



More information about the varnish-commit mailing list