Commit 05f81634 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Seamlessly hand over the per-sema mutex, to avoid silly context-switches



git-svn-id: http://www.varnish-cache.org/svn/trunk@4501 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent dad5b1f1
...@@ -93,7 +93,6 @@ sema_sync(struct sema *r, const char *av, struct vtclog *vl) ...@@ -93,7 +93,6 @@ sema_sync(struct sema *r, const char *av, struct vtclog *vl)
CHECK_OBJ_NOTNULL(r, SEMA_MAGIC); CHECK_OBJ_NOTNULL(r, SEMA_MAGIC);
u = strtoul(av, NULL, 0); u = strtoul(av, NULL, 0);
AZ(pthread_mutex_lock(&r->mtx));
if (r->expected == 0) if (r->expected == 0)
r->expected = u; r->expected = u;
if (r->expected != u) if (r->expected != u)
...@@ -111,7 +110,6 @@ sema_sync(struct sema *r, const char *av, struct vtclog *vl) ...@@ -111,7 +110,6 @@ sema_sync(struct sema *r, const char *av, struct vtclog *vl)
r->name, r->waiters, r->expected); r->name, r->waiters, r->expected);
AZ(pthread_cond_wait(&r->cond, &r->mtx)); AZ(pthread_cond_wait(&r->cond, &r->mtx));
} }
AZ(pthread_mutex_unlock(&r->mtx));
} }
/********************************************************************** /**********************************************************************
...@@ -148,8 +146,9 @@ cmd_sema(CMD_ARGS) ...@@ -148,8 +146,9 @@ cmd_sema(CMD_ARGS)
break; break;
if (r == NULL) if (r == NULL)
r = sema_new(av[0], vl); r = sema_new(av[0], vl);
AZ(pthread_mutex_unlock(&sema_mtx));
av++; av++;
AZ(pthread_mutex_lock(&r->mtx));
AZ(pthread_mutex_unlock(&sema_mtx));
for (; *av != NULL; av++) { for (; *av != NULL; av++) {
if (!strcmp(*av, "sync")) { if (!strcmp(*av, "sync")) {
...@@ -160,6 +159,7 @@ cmd_sema(CMD_ARGS) ...@@ -160,6 +159,7 @@ cmd_sema(CMD_ARGS)
} }
vtc_log(vl, 0, "Unknown sema argument: %s", *av); vtc_log(vl, 0, "Unknown sema argument: %s", *av);
} }
AZ(pthread_mutex_unlock(&r->mtx));
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment