You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2001/03/31 20:56:51 UTC

cvs commit: apr/test client.c

trawick     01/03/31 10:56:51

  Modified:    test     client.c
  Log:
  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.
  
  Revision  Changes    Path
  1.27      +7 -19     apr/test/client.c
  
  Index: client.c
  ===================================================================
  RCS file: /home/cvs/apr/test/client.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- client.c	2001/02/16 04:16:08	1.26
  +++ client.c	2001/03/31 18:56:50	1.27
  @@ -77,7 +77,7 @@
       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 @@
       }
       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 @@
       }
       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.......");