summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 23c8e0f)
raw | patch | inline | side by side (parent: 23c8e0f)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 20 Oct 2013 19:56:44 +0000 (21:56 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 20 Oct 2013 19:56:44 +0000 (21:56 +0200) |
src/utils/channel.c | patch | blob | history |
diff --git a/src/utils/channel.c b/src/utils/channel.c
index afce6f5d9cc9aa883afb9569aef9a384c433eb01..6db9b9512310b8d626ea12f73e33e90a5ff3d34e 100644 (file)
--- a/src/utils/channel.c
+++ b/src/utils/channel.c
sdb_channel_select(sdb_channel_t *chan, int *wantread, void *read_data,
int *wantwrite, void *write_data, const struct timespec *timeout)
{
- struct timespec abstime;
int status = 0;
if (! chan) {
return -1;
}
- if (timeout) {
- if (clock_gettime(CLOCK_REALTIME, &abstime))
- return -1;
-
- abstime.tv_sec += timeout->tv_sec;
- abstime.tv_nsec += timeout->tv_nsec;
- }
-
pthread_mutex_lock(&chan->lock);
while (! status) {
int read_status, write_status;
break;
}
- if (timeout)
+ if (timeout) {
+ struct timespec abstime;
+
+ if (clock_gettime(CLOCK_REALTIME, &abstime))
+ return -1;
+
+ abstime.tv_sec += timeout->tv_sec;
+ abstime.tv_nsec += timeout->tv_nsec;
+
status = pthread_cond_timedwait(&chan->cond, &chan->lock,
&abstime);
+ }
else
status = pthread_cond_wait(&chan->cond, &chan->lock);
}