From 67f92c44a462350e6bacccb353d39ed28ea4bf5e Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 20 Oct 2013 22:20:36 +0200 Subject: [PATCH] utils channel: Unlock mutex before returning on error. --- src/utils/channel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/channel.c b/src/utils/channel.c index 6db9b95..af41b47 100644 --- a/src/utils/channel.c +++ b/src/utils/channel.c @@ -202,8 +202,10 @@ sdb_channel_select(sdb_channel_t *chan, int *wantread, void *read_data, if (timeout) { struct timespec abstime; - if (clock_gettime(CLOCK_REALTIME, &abstime)) + if (clock_gettime(CLOCK_REALTIME, &abstime)) { + pthread_mutex_unlock(&chan->lock); return -1; + } abstime.tv_sec += timeout->tv_sec; abstime.tv_nsec += timeout->tv_nsec; @@ -214,8 +216,8 @@ sdb_channel_select(sdb_channel_t *chan, int *wantread, void *read_data, else status = pthread_cond_wait(&chan->cond, &chan->lock); } - pthread_mutex_unlock(&chan->lock); + if (status) { errno = status; return -1; -- 2.30.2