aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weasel.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/weasel.c b/weasel.c
index f683d70..07527b5 100644
--- a/weasel.c
+++ b/weasel.c
@@ -140,15 +140,15 @@ pickrandom()
{
int hasone = 0;
+ pthread_mutex_lock(&mutexsum);
while (!hasone) {
- pthread_mutex_lock(&mutexsum);
cp = generation[random() % population];
if (!cp->locked) {
cp->locked = 1;
hasone = 1;
}
- pthread_mutex_unlock(&mutexsum);
}
+ pthread_mutex_unlock(&mutexsum);
return cp;
}