mturk       2004/08/05 11:32:57

  Modified:    ajp/proxy proxy_util.c mod_proxy.h
  Log:
  Added ap_proxy_connection_create function that makes
  conn_rec for opened connection. It is used bt http(s) and ftp for
  bounding the backend connection to client connection with the same id's.
  
  Revision  Changes    Path
  1.16      +65 -4     jakarta-tomcat-connectors/ajp/proxy/proxy_util.c
  
  Index: proxy_util.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/proxy/proxy_util.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- proxy_util.c      5 Aug 2004 17:41:15 -0000       1.15
  +++ proxy_util.c      5 Aug 2004 18:32:57 -0000       1.16
  @@ -1636,9 +1636,70 @@
               backend_addr = backend_addr->next;
               continue;
           }
  -        conn->sock   = newsock;
  -        conn->worker = worker;
  -        connected    = 1;
  +        
  +        conn->sock     = newsock;
  +        conn->worker   = worker;
  +        /* XXX: the hostname will go from proxy_conn_rec
  +         * keep for now.
  +         * We will 'optimize' later, both code and unneeded data
  +         */
  +        conn->hostname = worker->hostname;
  +        connected      = 1;
       }
  -    return connected ? 0 : 1;
  +    return connected ? OK : DECLINED;
  +}
  +
  +PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
  +                                              proxy_conn_rec *conn,
  +                                              proxy_server_conf *conf,
  +                                              conn_rec *c,
  +                                              server_rec *s)
  +{
  +    proxy_worker *worker = conn->worker;
  +    apr_sockaddr_t *backend_addr = worker->cp->addr;
  +
  +    /* The socket is now open, create a new backend server connection 
  +    * 
  +    */
  +    conn->connection = ap_run_create_connection(c->pool, s, conn->sock,
  +                                                c->id, c->sbh,
  +                                                c->bucket_alloc);
  +
  +    if (!conn->connection) {
  +        /* the peer reset the connection already; ap_run_create_connection() 
  +        * closed the socket
  +        */
  +        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0,
  +                     s, "proxy: %s: an error occurred creating a "
  +                     "new connection to %pI (%s)", proxy_function,
  +                     backend_addr, conn->hostname);
  +        /* XXX: Will be closed when proxy_conn is closed */
  +        apr_socket_close(conn->sock);
  +        conn->sock = NULL;
  +        return HTTP_INTERNAL_SERVER_ERROR;
  +    }
  +
  +    /* For ssl connection to backend */
  +    if (conn->is_ssl) {
  +        if (!ap_proxy_ssl_enable(conn->connection)) {
  +            ap_log_error(APLOG_MARK, APLOG_ERR, 0,
  +                         s, "proxy: %s: failed to enable ssl support "
  +                         "for %pI (%s)", proxy_function, 
  +                         backend_addr, conn->hostname);
  +            return HTTP_INTERNAL_SERVER_ERROR;
  +        }
  +    }
  +    else {
  +        /* TODO: See if this will break FTP */
  +        ap_proxy_ssl_disable(conn->connection);
  +    }
  +
  +    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
  +                 "proxy: %s: connection complete to %pI (%s)",
  +                 proxy_function, backend_addr, conn->hostname);
  +
  +    /* set up the connection filters */
  +    ap_run_pre_connection(conn->connection, conn->sock);
  +
  +    return OK;
   }
  
  
  
  1.22      +2 -1      jakarta-tomcat-connectors/ajp/proxy/mod_proxy.h
  
  Index: mod_proxy.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/proxy/mod_proxy.h,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- mod_proxy.h       5 Aug 2004 17:46:58 -0000       1.21
  +++ mod_proxy.h       5 Aug 2004 18:32:57 -0000       1.22
  @@ -364,7 +364,8 @@
   PROXY_DECLARE(apr_status_t) ap_proxy_close_connection(proxy_conn_rec *conn);
   PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function, 
proxy_conn_rec *conn, proxy_worker *worker,
                                               proxy_server_conf *conf, server_rec *s);
  -
  +PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function, 
proxy_conn_rec *conn,
  +                                              proxy_server_conf *conf, conn_rec *c, 
server_rec *s);
   /* For proxy_util */
   extern module PROXY_DECLARE_DATA proxy_module;
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to