summaryrefslogtreecommitdiffstats
path: root/src/verify.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-08-02 06:44:34 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-08-02 06:45:39 +0200
commit4f25bdd2590f65586931ec71f798a91443e13674 (patch)
treeb1594588c8286c2f5f9d1caae1616c7d144e6fc1 /src/verify.c
parent96a291d11f884b18356ba8ef4b12b82d658d8d04 (diff)
downloadfastd-4f25bdd2590f65586931ec71f798a91443e13674.tar
fastd-4f25bdd2590f65586931ec71f798a91443e13674.zip
Encapsulate semaphore handling
Diffstat (limited to 'src/verify.c')
-rw-r--r--src/verify.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/verify.c b/src/verify.c
index 2031079..4f28faf 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -82,8 +82,7 @@ static void * do_verify_thread(void *p) {
free(arg);
- if (sem_post(&ctx.verify_limit))
- exit_errno("sem_post");
+ fastd_sem_post(&ctx.verify_limit);
return NULL;
}
@@ -110,7 +109,7 @@ fastd_tristate_t fastd_verify_peer(fastd_peer_t *peer, fastd_socket_t *sock, con
return ret ? fastd_tristate_true : fastd_tristate_false;
}
else {
- if (sem_trywait(&ctx.verify_limit)) {
+ if (!fastd_sem_trywait(&ctx.verify_limit)) {
pr_debug("maximum number of verification processes reached");
return fastd_tristate_false;
}
@@ -131,8 +130,7 @@ fastd_tristate_t fastd_verify_peer(fastd_peer_t *peer, fastd_socket_t *sock, con
if ((errno = pthread_create(&thread, &ctx.detached_thread, do_verify_thread, arg)) != 0) {
pr_error_errno("unable to create verify thread");
- if (sem_post(&ctx.verify_limit))
- exit_errno("sem_post");
+ fastd_sem_post(&ctx.verify_limit);
fastd_shell_env_free(env);
free(arg);