From 23c8e0f818e5baf91e75993571b67fcb735628f5 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 20 Oct 2013 21:38:23 +0200 Subject: [PATCH] utils channel: Let channel_select() set errno. --- src/utils/channel.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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 -- 2.30.2