diff options
author | Kirill Tkhai <ktkhai@virtuozzo.com> | 2017-01-25 12:46:19 +0300 |
---|---|---|
committer | Pavel Emelyanov <xemul@virtuozzo.com> | 2017-02-03 18:04:22 +0300 |
commit | 6a3cfcd5502dc78d8c6785cfcadaf64e8baa9933 (patch) | |
tree | dbccacb10fda1e03f5e803a4899787586683822e /include | |
parent | 25d59cb2bf5b8099d29cadcb5509003242b8896c (diff) |
scm: Return sensible error codes in recv_fds()
Replace "-1" return with errno codes.
ENOMSG and EBADFD were choosen to do not cross with
standard recvmsg() errors (described in its man page).
This patch is need as preparation to making recv_msg()
be able to be non-block, and return EAGAIN and EWOULDBLOCK
in case of no data.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/common/scm-code.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/common/scm-code.c b/include/common/scm-code.c index 504c97212..4015405d2 100644 --- a/include/common/scm-code.c +++ b/include/common/scm-code.c @@ -90,7 +90,7 @@ int recv_fds(int sock, int *fds, int nr_fds, void *data, unsigned ch_size) ret = __sys(recvmsg)(sock, &fdset.hdr, 0); if (ret <= 0) - return ret ? : -1; + return ret ? __sys_err(ret) : -ENOMSG; cmsg = CMSG_FIRSTHDR(&fdset.hdr); if (!cmsg || cmsg->cmsg_type != SCM_RIGHTS) @@ -111,7 +111,7 @@ int recv_fds(int sock, int *fds, int nr_fds, void *data, unsigned ch_size) BUG_ON(min_fd > CR_SCM_MAX_FD); if (unlikely(min_fd <= 0)) - return -1; + return -EBADFD; __memcpy(&fds[i], cmsg_data, sizeof(int) * min_fd); if (data) |