mturk       2004/07/27 08:54:14

  Modified:    ajp/ajplib/test httpd_wrap.h httpd_wrap.c
  Log:
  Added ap_run_create_connection wrapper.
  
  Revision  Changes    Path
  1.2       +48 -2     jakarta-tomcat-connectors/ajp/ajplib/test/httpd_wrap.h
  
  Index: httpd_wrap.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/ajplib/test/httpd_wrap.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- httpd_wrap.h      27 Jul 2004 11:42:57 -0000      1.1
  +++ httpd_wrap.h      27 Jul 2004 15:54:13 -0000      1.2
  @@ -63,6 +63,35 @@
   struct conn_rec {
       /** Pool associated with this connection */
       apr_pool_t *pool;
  +    /** Physical vhost this conn came in on */
  +    server_rec *base_server;
  +    /* Information about the connection itself */
  +    /** local address */
  +    apr_sockaddr_t *local_addr;
  +    /** remote address */
  +    apr_sockaddr_t *remote_addr;
  +    /** Client's IP address */
  +    char *remote_ip;
  +    /** Client's DNS name, if known.  NULL if DNS hasn't been checked,
  +     *  "" if it has and no address was found.  N.B. Only access this though
  +     * get_remote_host() */
  +    char *remote_host; 
  +    /** How many times have we used it? */
  +    int keepalives;
  +    /** server IP address */
  +    char *local_ip;
  +    /** used for ap_get_server_name when UseCanonicalName is set to DNS
  +     *  (ignores setting of HostnameLookups) */
  +    char *local_host;
  +     /** ID of this connection; unique at any point in time */
  +    long id;
  +    /** send note from one module to another, must remain valid for all
  +     *  requests on this conn */
  +    apr_table_t *notes; 
  +    /** handle to scoreboard information for this connection */
  +    void *sbh; 
  +    /** The bucket allocator to use for all bucket/brigade creations */
  +    struct apr_bucket_alloc_t *bucket_alloc;
   };
   
   /** A structure to store information for each virtual server */
  @@ -186,8 +215,25 @@
                                  apr_status_t status, const request_rec *r, 
                                  const char *fmt, ...)
                   __attribute__((format(printf,6,7)));
  -
  -
  +/**
  + * create_connection is a RUN_FIRST hook which allows modules to create 
  + * connections. In general, you should not install filters with the 
  + * create_connection hook. If you require vhost configuration information 
  + * to make filter installation decisions, you must use the pre_connection
  + * or install_network_transport hook. This hook should close the connection
  + * if it encounters a fatal error condition.
  + *
  + * @param p The pool from which to allocate the connection record
  + * @param csd The socket that has been accepted
  + * @param conn_id A unique identifier for this connection.  The ID only
  + *                needs to be unique at that time, not forever.
  + * @param sbh A handle to scoreboard information for this connection.
  + * @return An allocated connection record or NULL.
  + */ 
  +AP_DECLARE(conn_rec *) ap_run_create_connection(apr_pool_t *ptrans,
  +                                  server_rec *server,
  +                                  apr_socket_t *csd, long id, void *sbh,
  +                                  apr_bucket_alloc_t *alloc);
   
   
   
  
  
  
  1.3       +44 -1     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- httpd_wrap.c      27 Jul 2004 12:09:12 -0000      1.2
  +++ httpd_wrap.c      27 Jul 2004 15:54:13 -0000      1.3
  @@ -85,7 +85,7 @@
               fprintf(stream, "(OS %d)", status - APR_OS_START_SYSERR);
           }
           else {
  -            fprintf(stream, "os 0x%08x)", status - APR_OS_START_SYSERR);
  +            fprintf(stream, "(os 0x%08x)", status - APR_OS_START_SYSERR);
           }
           apr_strerror(status, errstr, MAX_STRING_LEN);
           fprintf(stream, " %s ", errstr);
  @@ -132,3 +132,46 @@
       log_error_core(file, line, level, status, fmt, args);
       va_end(args);
   }
  +
  +
  +AP_DECLARE(conn_rec *) ap_run_create_connection(apr_pool_t *ptrans,
  +                                  server_rec *server,
  +                                  apr_socket_t *csd, long id, void *sbh,
  +                                  apr_bucket_alloc_t *alloc)
  +{
  +    apr_status_t rv;
  +    conn_rec *c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec));
  +
  +    c->sbh = sbh;
  +
  +    /* Got a connection structure, so initialize what fields we can
  +     * (the rest are zeroed out by pcalloc).
  +     */
  +    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;
  +    }
  +
  +    apr_sockaddr_ip_get(&c->remote_ip, c->remote_addr);
  +    c->base_server = server;
  +
  +    c->id = id;
  +    c->bucket_alloc = alloc;
  +
  +    return c;
  +} 
  
  
  

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

Reply via email to