diff options
author | Marek Vavrusa <marek.vavrusa@nic.cz> | 2013-01-07 13:12:45 +0100 |
---|---|---|
committer | Marek Vavrusa <marek.vavrusa@nic.cz> | 2013-01-07 13:12:45 +0100 |
commit | e847c49165f7d189b9b1ffe998eafed2fa331788 (patch) | |
tree | d019f4c0590c5dda546fa9ead7ae37f72c02dce1 | |
parent | Versioned as 1.2-rc1 (diff) | |
download | knot-1.2-rc1.tar.xz knot-1.2-rc1.zip |
Fixed potential race condition.v1.2.0-rc1v1.2-rc1
-rw-r--r-- | src/common/evsched.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/common/evsched.c b/src/common/evsched.c index 51035347d..5e2073af2 100644 --- a/src/common/evsched.c +++ b/src/common/evsched.c @@ -185,6 +185,7 @@ event_t* evsched_next(evsched_t *s) /* Immediately return. */ if (timercmp_ge(&dt, &next_ev->tv)) { s->cur = next_ev; + heap_delmin(&s->heap); pthread_mutex_unlock(&s->mx); pthread_mutex_lock(&s->rl); @@ -193,10 +194,7 @@ event_t* evsched_next(evsched_t *s) pthread_mutex_unlock(&s->rl); pthread_mutex_lock(&s->mx); continue; - } else { - /* Valid, remove from waitlist. */ - heap_delmin(&s->heap); - } + } return next_ev; } @@ -326,9 +324,7 @@ int evsched_cancel(evsched_t *s, event_t *ev) */ if (s->cur == ev) { s->cur = NULL; /* Invalidate */ - pthread_mutex_unlock(&s->mx); - pthread_mutex_unlock(&s->rl); - return found; + found = 1; /* Mark as found (although not in heap). */ } /* Unlock calendar. */ |