summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>2000-02-14 13:43:39 +0000
committerrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>2000-02-14 13:43:39 +0000
commit548554f7ca2e63277ec56d4f141b633e8e4400d4 (patch)
tree5cf7e3631306e84279a45b50b8e5a76e06f9f278
parent48cf2226c05b71f312442f344d9a12555cdd1912 (diff)
downloadlibapr-548554f7ca2e63277ec56d4f141b633e8e4400d4.tar.gz
Fix some bugs in ap_send and ap_recv. We used to return APR_SUCCESS even
when it didn't succeed. The other problem this is solving, is that we never set the length to -1 anymore. The length is the number of bytes written or read, as such -1 makes no sense. If there is an error, 0 bytes were written, so len should be 0. Submitted by: Manoj Kasichainula and Ryan Bloom git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@59652 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--network_io/unix/sendrecv.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/network_io/unix/sendrecv.c b/network_io/unix/sendrecv.c
index f879f1b67..682117ba2 100644
--- a/network_io/unix/sendrecv.c
+++ b/network_io/unix/sendrecv.c
@@ -108,17 +108,21 @@ ap_status_t ap_send(struct socket_t *sock, const char *buf, ap_ssize_t *len)
} while (srv == -1 && errno == EINTR);
if (srv == 0) {
- (*len) = -1;
+ (*len) = 0;
return APR_TIMEUP;
}
else if (srv < 0) {
- (*len) = -1;
+ (*len) = 0;
return errno;
}
else {
do {
rv = write(sock->socketdes, buf, (*len));
} while (rv == -1 && errno == EINTR);
+ if (rv == -1) {
+ (*len) = 0;
+ return errno;
+ }
}
}
(*len) = rv;
@@ -175,6 +179,10 @@ ap_status_t ap_recv(struct socket_t *sock, char *buf, ap_ssize_t *len)
do {
rv = read(sock->socketdes, buf, (*len));
} while (rv == -1 && errno == EINTR);
+ if (rv == -1) {
+ (*len) = 0;
+ return errno;
+ }
}
}
else if (rv == -1 && errno == EAGAIN && sock->timeout == 0) {