diff --git a/src/cond/zm_scount.c b/src/cond/zm_scount.c index 603b4b0..e1b2d90 100644 --- a/src/cond/zm_scount.c +++ b/src/cond/zm_scount.c @@ -27,21 +27,20 @@ int zm_scount_wait(struct zm_scount *C, zm_lock_t *L) { return 0; } -int zm_scount_signal(struct zm_scount *C) { +int zm_scount_signal(struct zm_scount *C, int *out_count) { int ret = 0; if(C->count > 0) { C->count--; if(C->count == 0) ret = zm_ccond_signal(&C->cvar); } + *out_count = C->count; return ret; } /* Forced wake up regardless of the counter */ int zm_scond_signalf(struct zm_scount *C) { int ret = 0; - if(C->count > 0) - C->count--; /* wakeup signal regardless of the counter value */ ret = zm_ccond_signal(&C->cvar); diff --git a/src/include/cond/zm_scount.h b/src/include/cond/zm_scount.h index 59e6831..6babaa0 100644 --- a/src/include/cond/zm_scount.h +++ b/src/include/cond/zm_scount.h @@ -11,7 +11,7 @@ int zm_scount_init(struct zm_scount *C, int); int zm_scount_destroy(struct zm_scount *C); int zm_scount_wait(struct zm_scount *C, zm_lock_t *L); -int zm_scount_signal(struct zm_scount *C); +int zm_scount_signal(struct zm_scount *C, int*); int zm_scount_signalf(struct zm_scount *C); #endif /* _ZM_SCOND_H */ diff --git a/test/regres/cond/prio_chain.c b/test/regres/cond/prio_chain.c index 4ecf761..2360921 100644 --- a/test/regres/cond/prio_chain.c +++ b/test/regres/cond/prio_chain.c @@ -44,7 +44,8 @@ static void* run(void *arg) { counter++; for(int i = 1; i