From: Sebastian Harl Date: Sun, 20 Oct 2013 20:20:36 +0000 (+0200) Subject: utils channel: Unlock mutex before returning on error. X-Git-Tag: sysdb-0.1.0~336^2~48 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=67f92c44a462350e6bacccb353d39ed28ea4bf5e;p=sysdb.git utils channel: Unlock mutex before returning on error. --- 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;