diff options
author | Sander Vrijders <sander.vrijders@ugent.be> | 2017-03-28 08:38:05 +0000 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@ugent.be> | 2017-03-28 08:38:05 +0000 |
commit | ba13c05b8b61365ff9e969c15affd2e1d52b76ed (patch) | |
tree | baa5d6178914dd12106845ca81c81b63e4249c6f /src/lib | |
parent | 7ee6dadd39f3d4b5874d23bfcdcdd66eb195124e (diff) | |
parent | 6d080d9b9ee2e480717935e4ce94870fc87ea5f7 (diff) | |
download | ouroboros-ba13c05b8b61365ff9e969c15affd2e1d52b76ed.tar.gz ouroboros-ba13c05b8b61365ff9e969c15affd2e1d52b76ed.zip |
Merged in sandervrijders/ouroboros/be-upd-graph (pull request #426)
Be upd graph
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/list.c | 12 | ||||
-rw-r--r-- | src/lib/rib.c | 12 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/lib/list.c b/src/lib/list.c index b6b4bbd2..d5aba058 100644 --- a/src/lib/list.c +++ b/src/lib/list.c @@ -71,13 +71,9 @@ bool list_is_empty(struct list_head * h) return h->nxt == h; } -void list_move(struct list_head * dst, - struct list_head * src) +void list_move(struct list_head * n, + struct list_head * h) { - dst->nxt = src->nxt; - dst->prv = src->prv; - dst->nxt->prv = src->nxt->prv; - dst->prv->nxt = src->prv->nxt; - - list_head_init(src); + del_list(n->prv, n->nxt); + add_list(n, h, h->nxt); } diff --git a/src/lib/rib.c b/src/lib/rib.c index fc58f266..d39a17d2 100644 --- a/src/lib/rib.c +++ b/src/lib/rib.c @@ -1114,6 +1114,7 @@ int rib_event_wait(ro_set_t * set, { struct rib_sub * sub; struct timespec abstime; + struct revent * ev; ssize_t ret = 0; @@ -1136,6 +1137,9 @@ int rib_event_wait(ro_set_t * set, pthread_mutex_lock(&sub->lock); + pthread_cleanup_push((void(*)(void *)) pthread_mutex_unlock, + (void *) &sub->lock); + while (list_is_empty(&sub->events) && ret != -ETIMEDOUT) { if (timeout != NULL) ret = -pthread_cond_timedwait(&sub->cond, @@ -1145,12 +1149,14 @@ int rib_event_wait(ro_set_t * set, ret = -pthread_cond_wait(&sub->cond, &sub->lock); } - pthread_mutex_unlock(&sub->lock); + pthread_cleanup_pop(true); pthread_rwlock_wrlock(&rib.lock); - if (ret != -ETIMEDOUT) - list_move(&rq->events, &sub->events); + if (ret != -ETIMEDOUT) { + ev = list_first_entry(&sub->events, struct revent, next); + list_move(&ev->next, &rq->events); + } pthread_rwlock_unlock(&rib.lock); |