diff options
Diffstat (limited to 'source4/lib/util_sock.c')
-rw-r--r-- | source4/lib/util_sock.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/source4/lib/util_sock.c b/source4/lib/util_sock.c index 43da8a2f57..8c9a140746 100644 --- a/source4/lib/util_sock.c +++ b/source4/lib/util_sock.c @@ -195,10 +195,13 @@ ssize_t read_data(int fd, char *buffer, size_t N) while (total < N) { ret = sys_read(fd,buffer + total,N - total); if (ret == 0) { - return 0; + return total; } if (ret == -1) { - return -1; + if (total == 0) { + return -1; + } + return total; } total += ret; } @@ -222,10 +225,14 @@ ssize_t write_data(int fd, const char *buffer, size_t N) while (total < N) { ret = sys_write(fd, buffer + total, N - total); if (ret == -1) { - return -1; + if (total == 0) { + return -1; + } + return total; } - if (ret == 0) + if (ret == 0) { return total; + } total += ret; } |