mturk       2004/07/27 10:28:31

  Modified:    ajp/ajplib/test testajp.c httpd_wrap.c
  Log:
  Add create_connection test case. Rewrite create_connection, so if the
  socket is missing (we don't have a client) the address is set to localhost.
  
  Revision  Changes    Path
  1.3       +20 -2     jakarta-tomcat-connectors/ajp/ajplib/test/testajp.c
  
  Index: testajp.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/ajplib/test/testajp.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- testajp.c 27 Jul 2004 12:09:12 -0000      1.2
  +++ testajp.c 27 Jul 2004 17:28:31 -0000      1.3
  @@ -39,20 +39,38 @@
   #include <arpa/inet.h>
   #endif
   
  +int test_create_conn(apr_pool_t *pool)
  +{
  +    conn_rec *c;
  +    
  +    if (!(c = ap_run_create_connection(pool, NULL, NULL,
  +                                       0, NULL, NULL)))
  +        return -1;
  +    ap_log_error(APLOG_MARK, APLOG_INFO, 0, NULL, "local ip %s:%d", 
  +                 c->local_ip, c->local_addr->port);
  +        
  +    return 0;
  +}
  +
  +
   int main(int argc, const char * const * argv, const char * const *env)
   {
       int rv = 0;
  -
  +    apr_pool_t *ctx;
       apr_app_initialize(&argc, &argv, &env);
   
  +    apr_pool_create(&ctx, NULL);
       /* This is done in httpd.conf using LogLevel debug directive.
        * We are setting this directly.
        */
       ap_default_loglevel = APLOG_DEBUG;
   
       ap_log_error(APLOG_MARK, APLOG_INFO, 0, NULL, "Testing ajp...");
  +    ap_log_error(APLOG_MARK, APLOG_INFO, 0, NULL, "create conn...");
  +    if ((rv = test_create_conn(ctx)))
  +        goto finished;
   
  -
  +finished:
       ap_log_error(APLOG_MARK, APLOG_INFO, 0, NULL, "%s", rv == 0 ? "OK" : "FAILED");
       apr_terminate();
   }
  
  
  
  1.5       +34 -15    jakarta-tomcat-connectors/ajp/ajplib/test/httpd_wrap.c
  
  Index: httpd_wrap.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/ajplib/test/httpd_wrap.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- httpd_wrap.c      27 Jul 2004 16:28:05 -0000      1.4
  +++ httpd_wrap.c      27 Jul 2004 17:28:31 -0000      1.5
  @@ -179,23 +179,42 @@
       c->notes = apr_table_make(ptrans, 5);
   
       c->pool = ptrans;
  -    if ((rv = apr_socket_addr_get(&c->local_addr, APR_LOCAL, csd))
  -        != APR_SUCCESS) {
  -        ap_log_error(APLOG_MARK, APLOG_INFO, rv, server,
  -                     "apr_socket_addr_get(APR_LOCAL)");
  -        apr_socket_close(csd);
  -        return NULL;
  -    }
   
  -    apr_sockaddr_ip_get(&c->local_ip, c->local_addr);
  -    if ((rv = apr_socket_addr_get(&c->remote_addr, APR_REMOTE, csd))
  -        != APR_SUCCESS) {
  -        ap_log_error(APLOG_MARK, APLOG_INFO, rv, server,
  -                     "apr_socket_addr_get(APR_REMOTE)");
  -        apr_socket_close(csd);
  -        return NULL;
  +    /* Socket is used only for backend connections
  +     * Since we don't have client socket skip the 
  +     * creation of adresses. They will be default
  +     * to 127.0.0.1:0 both local and remote
  +     */
  +    if (csd) {
  +        if ((rv = apr_socket_addr_get(&c->local_addr, APR_LOCAL, csd))
  +            != APR_SUCCESS) {
  +                ap_log_error(APLOG_MARK, APLOG_INFO, rv, server,
  +                    "apr_socket_addr_get(APR_LOCAL)");
  +                apr_socket_close(csd);
  +                return NULL;
  +         }
  +         if ((rv = apr_socket_addr_get(&c->remote_addr, APR_REMOTE, csd))
  +                != APR_SUCCESS) {
  +            ap_log_error(APLOG_MARK, APLOG_INFO, rv, server,
  +                    "apr_socket_addr_get(APR_REMOTE)");
  +                apr_socket_close(csd);
  +            return NULL;
  +         }
  +    } 
  +    else {
  +        /* localhost should be reachable on all platforms */
  +        if ((rv = apr_sockaddr_info_get(&c->local_addr, "localhost",
  +                                        APR_UNSPEC, 0,
  +                                        APR_IPV4_ADDR_OK, 
  +                                        c->pool))
  +            != APR_SUCCESS) {
  +                ap_log_error(APLOG_MARK, APLOG_INFO, rv, server,
  +                    "apr_sockaddr_info_get()");
  +                return NULL;
  +         }
  +         c->remote_addr = c->local_addr;        
       }
  -
  +    apr_sockaddr_ip_get(&c->local_ip, c->local_addr);
       apr_sockaddr_ip_get(&c->remote_ip, c->remote_addr);
       c->base_server = server;
   
  
  
  

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

Reply via email to