X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsem.c;h=b4c4a89b5135ddeacbb76a22f735c1f62bddb847;hb=HEAD;hp=c18445361fb1fcccd6233a2c98460232d84457ae;hpb=c5059d4c1e7f0de5a466d471e7ee26b6ccce8396;p=tlsproxy%2Ftlsproxy.git diff --git a/src/sem.c b/src/sem.c index c184453..b4c4a89 100644 --- a/src/sem.c +++ b/src/sem.c @@ -1,7 +1,7 @@ /* * Simple semaphore implementation, P() and V(). * - * Copyright (C) 2011-2013 Simon Ruderich + * Copyright (C) 2011-2014 Simon Ruderich * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,8 +19,8 @@ #include "sem.h" -#include #include +#include struct SEM { @@ -69,7 +69,7 @@ int sem_del(SEM *sem) { void P(SEM *sem) { pthread_mutex_lock(&sem->mutex); - while (sem->value == 0) { + while (sem->value <= 0) { pthread_cond_wait(&sem->condition, &sem->mutex); } sem->value--;