httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: httpd-2.0/modules/proxy proxy_connect.c
Date Fri, 04 Jan 2002 18:32:48 GMT
trawick     02/01/04 10:32:48

  Modified:    .        CHANGES
               modules/proxy proxy_connect.c
  Log:
  for proxy CONNECT handling:
  
    don't hard-code the address family of the target; respect
    what the resolver told us
  
    get a new socket each time we try to connect to one of the
    target addresses as reported by the resolver; you can't
    portably attempt to connect more than once on the same
    socket
  
  this is the same fix committed to proxy http support yesterday
  
  Revision  Changes    Path
  1.502     +4 -3      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.501
  retrieving revision 1.502
  diff -u -r1.501 -r1.502
  --- CHANGES	4 Jan 2002 01:47:55 -0000	1.501
  +++ CHANGES	4 Jan 2002 18:32:48 -0000	1.502
  @@ -1,8 +1,9 @@
   Changes with Apache 2.0.30-dev
   
  -  *) Fix a couple of mod_proxy problems forwarding HTTP connections:
  -     (1) PR #9190  It failed to connect to IPv6 hosts.
  -     (2) It failed to connect when the first IP address returned by 
  +  *) Fix a couple of mod_proxy problems forwarding HTTP connections
  +     and handling CONNECT:
  +     (1) PR #9190  Proxy failed to connect to IPv6 hosts.
  +     (2) Proxy failed to connect when the first IP address returned by 
            the resolver was unreachable but a secondary IP address was.  
        [Jeff Trawick]
   
  
  
  
  1.52      +18 -12    httpd-2.0/modules/proxy/proxy_connect.c
  
  Index: proxy_connect.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_connect.c,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- proxy_connect.c	14 Nov 2001 21:18:46 -0000	1.51
  +++ proxy_connect.c	4 Jan 2002 18:32:48 -0000	1.52
  @@ -216,16 +216,6 @@
                                connectname, NULL));
       }
   
  -    /* create a new socket */
  -    if ((rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, r->pool)) != APR_SUCCESS)
{
  -        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
  -            "proxy: error creating socket");
  -        return HTTP_INTERNAL_SERVER_ERROR;
  -    }
  -
  -    /* Set a timeout on the socket */
  -    apr_setsocketopt(sock, APR_SO_TIMEOUT, (int)(r->server->timeout * APR_USEC_PER_SEC));
  -
   	/*
   	 * At this point we have a list of one or more IP addresses of
   	 * the machine to connect to. If configured, reorder this
  @@ -235,19 +225,36 @@
            *
            * For now we do nothing, ie we get DNS round robin.
   	 * XXX FIXME
  +         *
  +         * We have to create a new socket each time through the loop because
  +         *
  +         *   (1) On most stacks, connect() fails with EINVAL or similar if
  +         *       we previously failed connect() on the socket in the past
  +         *   (2) The address family of the socket needs to match that of the
  +         *       address we're trying to connect to.
   	 */
   
  -
       /* try each IP address until we connect successfully */
       {
   	int failed = 1;
   	while (connect_addr) {
   
  +            /* create a new socket */
  +            if ((rv = apr_socket_create(&sock, connect_addr->family, SOCK_STREAM,
r->pool)) != APR_SUCCESS) {
  +                ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
  +                              "proxy: error creating socket");
  +                return HTTP_INTERNAL_SERVER_ERROR;
  +            }
  +
  +            /* Set a timeout on the socket */
  +            apr_setsocketopt(sock, APR_SO_TIMEOUT, (int)(r->server->timeout * APR_USEC_PER_SEC));
  +
   	    /* make the connection out of the socket */
   	    rv = apr_connect(sock, connect_addr);
   
   	    /* if an error occurred, loop round and try again */
               if (rv != APR_SUCCESS) {
  +                apr_socket_close(sock);
   		ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
   			     "proxy: CONNECT: attempt to connect to %pI (%s) failed", connect_addr, connectname);
   		connect_addr = connect_addr->next;
  @@ -261,7 +268,6 @@
   
   	/* handle a permanent error from the above loop */
   	if (failed) {
  -	    apr_socket_close(sock);
   	    if (proxyname) {
   		return DECLINED;
   	    }
  
  
  

Mime
View raw message