summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-07-29 11:55:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:57:44 -0500
commit578a99db4d43827ac78ca6bf94e89c883a3dd310 (patch)
tree42f95c990f0000ac19dc3a3e05634cb9d857898f
parent188a8014ea77e8d03916da8b6bc103bc49086155 (diff)
downloadsamba-578a99db4d43827ac78ca6bf94e89c883a3dd310.tar.gz
samba-578a99db4d43827ac78ca6bf94e89c883a3dd310.tar.bz2
samba-578a99db4d43827ac78ca6bf94e89c883a3dd310.zip
r1606: make the low level socket read/write routines cope properly with non-blocking sockets
(This used to be commit bb6cbf29ccf8f2b556bf3e7b3ff487faa0f36773)
-rw-r--r--source4/lib/util_sock.c15
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;
}