diff options
author | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2001-03-31 18:56:50 +0000 |
---|---|---|
committer | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2001-03-31 18:56:50 +0000 |
commit | 7b461e71d5d76b74747f23293f00c4bf6eefe560 (patch) | |
tree | 7d5477bf9017f1aea5dc4b5c2e64288e3033a044 | |
parent | a86037b7ef351b5553d93d5e716ebd5ad6a976b6 (diff) | |
download | libapr-7b461e71d5d76b74747f23293f00c4bf6eefe560.tar.gz |
We didn't have logic to retry an EAGAIN error from apr_recv(),
which made no sense (but somehow never broke the program when
I ran on *ix). It did break on Win98.
The fix is to use APR timeouts always. We default to 2 seconds.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61416 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | test/client.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/test/client.c b/test/client.c index cdb7495b3..bb5d3db63 100644 --- a/test/client.c +++ b/test/client.c @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) char *local_ipaddr, *remote_ipaddr; char *dest = "127.0.0.1"; apr_port_t local_port, remote_port; - apr_interval_time_t read_timeout = -1; + apr_interval_time_t read_timeout = 2 * APR_USEC_PER_SEC; apr_sockaddr_t *local_sa, *remote_sa; setbuf(stdout, NULL); @@ -135,16 +135,6 @@ int main(int argc, char *argv[]) } fprintf(stdout, "OK\n"); - if (read_timeout == -1) { - fprintf(stdout, "\tClient: Setting socket option NONBLOCK......."); - if (apr_setsocketopt(sock, APR_SO_NONBLOCK, 1) != APR_SUCCESS) { - apr_socket_close(sock); - fprintf(stderr, "Couldn't set socket option\n"); - exit(-1); - } - fprintf(stdout, "OK\n"); - } - apr_socket_addr_get(&remote_sa, APR_REMOTE, sock); apr_sockaddr_ip_get(&remote_ipaddr, remote_sa); apr_sockaddr_port_get(&remote_port, remote_sa); @@ -162,15 +152,13 @@ int main(int argc, char *argv[]) } fprintf(stdout, "OK\n"); - if (read_timeout != -1) { - fprintf(stdout, "\tClient: Setting read timeout......."); - stat = apr_setsocketopt(sock, APR_SO_TIMEOUT, read_timeout); - if (stat) { - fprintf(stderr, "Problem setting timeout: %d\n", stat); - exit(-1); - } - fprintf(stdout, "OK\n"); + fprintf(stdout, "\tClient: Setting read timeout......."); + stat = apr_setsocketopt(sock, APR_SO_TIMEOUT, read_timeout); + if (stat) { + fprintf(stderr, "Problem setting timeout: %d\n", stat); + exit(-1); } + fprintf(stdout, "OK\n"); length = STRLEN; fprintf(stdout, "\tClient: Trying to receive data over socket......."); |