From: Sebastian Harl Date: Sun, 20 Oct 2013 19:38:23 +0000 (+0200) Subject: utils channel: Let channel_select() set errno. X-Git-Tag: sysdb-0.1.0~336^2~50 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=23c8e0f818e5baf91e75993571b67fcb735628f5;p=sysdb.git utils channel: Let channel_select() set errno. --- diff --git a/src/utils/channel.c b/src/utils/channel.c index 92d793e..afce6f5 100644 --- a/src/utils/channel.c +++ b/src/utils/channel.c @@ -29,6 +29,8 @@ #include +#include + #include #include @@ -170,11 +172,15 @@ sdb_channel_select(sdb_channel_t *chan, int *wantread, void *read_data, struct timespec abstime; int status = 0; - if (! chan) + if (! chan) { + errno = EINVAL; return -1; + } - if ((! wantread) && (! read_data) && (! wantwrite) && (! write_data)) + if ((! wantread) && (! read_data) && (! wantwrite) && (! write_data)) { + errno = EINVAL; return -1; + } if (timeout) { if (clock_gettime(CLOCK_REALTIME, &abstime)) @@ -210,7 +216,11 @@ sdb_channel_select(sdb_channel_t *chan, int *wantread, void *read_data, } pthread_mutex_unlock(&chan->lock); - return status; + if (status) { + errno = status; + return -1; + } + return 0; } /* sdb_channel_select */ int