From e3c99ae355408933b03357220f3db09423bd40dd Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 2 Apr 2012 17:22:16 -0400 Subject: sss_atomic_io: Do not fail reads with EPIPE if there is not enough data to read Also adds a unit test for sss_atomic_io() --- src/util/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/util') diff --git a/src/util/util.c b/src/util/util.c index 8e20ab71..3a6c5d27 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -639,7 +639,8 @@ ssize_t sss_atomic_io(int fd, void *buf, size_t n, bool do_read) } return -1; case 0: - errno = EPIPE; + /* read returns 0 on end-of-file */ + errno = do_read ? 0 : EPIPE; return pos; default: pos += (size_t) res; -- cgit