From 578a99db4d43827ac78ca6bf94e89c883a3dd310 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 29 Jul 2004 11:55:57 +0000 Subject: r1606: make the low level socket read/write routines cope properly with non-blocking sockets (This used to be commit bb6cbf29ccf8f2b556bf3e7b3ff487faa0f36773) --- source4/lib/util_sock.c | 15 +++++++++++---- 1 file 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; } -- cgit