httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@apache.org
Subject cvs commit: httpd-2.0/server/mpm/worker worker.c
Date Fri, 01 Feb 2002 22:16:31 GMT
stoddard    02/02/01 14:16:31

  Modified:    include  http_connection.h
               modules/proxy proxy_ftp.c proxy_http.c
               server   connection.c core.c
               server/mpm/beos beos.c
               server/mpm/mpmt_os2 mpmt_os2_child.c
               server/mpm/netware mpm_netware.c
               server/mpm/perchild perchild.c
               server/mpm/prefork prefork.c
               server/mpm/winnt mpm_winnt.c
               server/mpm/worker worker.c
  Log:
  Reintroduce the create_connection hook. This hook is required to enable
  modules to completely take over all network i/o from the core.
  
  Revision  Changes    Path
  1.51      +22 -18    httpd-2.0/include/http_connection.h
  
  Index: http_connection.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/http_connection.h,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- http_connection.h	29 Jan 2002 19:02:02 -0000	1.50
  +++ http_connection.h	1 Feb 2002 22:16:30 -0000	1.51
  @@ -65,21 +65,8 @@
   /**
    * @package Apache connection library
    */
  -
   #ifdef CORE_PRIVATE
   /**
  - * Create a new connection. 
  - * @param p Pool to allocate data structures out of
  - * @param server The server to create the connection for
  - * @param csd The socket to use for all communication with the client
  - * @param id ID of this connection; unique at any point in time.
  - * @param sbh Scoreboard handle
  - * @return new conn_rec, or NULL if the connection has already been reset
  - */
  -AP_CORE_DECLARE(conn_rec *)ap_new_connection(apr_pool_t *ptrans, server_rec *server, 
  -                                             apr_socket_t *csd, long id, void *sbh);
  -
  -/**
    * This is the protocol module driver.  This calls all of the
    * pre-connection and connection hooks for all protocol modules.
    * @param c The connection on which the request is read
  @@ -109,11 +96,28 @@
   
     /* Hooks */
   /**
  - * This hook is used to install the bottom most input and output
  - * filters (e.g., CORE_IN and CORE_OUT) used to interface to the 
  - * network. This filter is a RUN_FIRST hook that runs right before
  - * the pre_connection filter. This filter hook can use vhost 
  - * configuration to influence its operation.
  + * 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_HOOK(conn_rec *, create_connection,
  +                (apr_pool_t *p, server_rec *server, apr_socket_t *csd, long conn_id, void
*sbh))
  +   
  +/**
  + * install_transport_filters is a RUN_FIRST hook used to install the bottom 
  + * most input and output network transport filters (e.g., CORE_IN and CORE_OUT) 
  + * used to interface to the network. This hook can access vhost configuration.
  + *
    * @param c The socket to the client
    * @param csd Pointer to the client apr_socket_t struct.
    * @return OK or DECLINED
  
  
  
  1.106     +4 -4      httpd-2.0/modules/proxy/proxy_ftp.c
  
  Index: proxy_ftp.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_ftp.c,v
  retrieving revision 1.105
  retrieving revision 1.106
  diff -u -r1.105 -r1.106
  --- proxy_ftp.c	31 Jan 2002 14:48:51 -0000	1.105
  +++ proxy_ftp.c	1 Feb 2002 22:16:30 -0000	1.106
  @@ -1017,10 +1017,10 @@
       }
   
       /* the socket is now open, create a new connection */
  -    origin = ap_new_connection(p, r->server, sock, r->connection->id, r->connection->sbh);
  +    origin = ap_run_create_connection(p, r->server, sock, r->connection->id, r->connection->sbh);
       if (!origin) {
           /*
  -         * the peer reset the connection already; ap_new_connection() closed
  +         * the peer reset the connection already; ap_run_create_connection() closed
            * the socket
            */
           ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
  @@ -1778,10 +1778,10 @@
       }
   
       /* the transfer socket is now open, create a new connection */
  -    data = ap_new_connection(p, r->server, data_sock, r->connection->id, r->connection->sbh);
  +    data = ap_run_create_connection(p, r->server, data_sock, r->connection->id,
r->connection->sbh);
       if (!data) {
           /*
  -         * the peer reset the connection already; ap_new_connection() closed
  +         * the peer reset the connection already; ap_run_create_connection() closed
            * the socket
            */
           ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
  
  
  
  1.128     +3 -3      httpd-2.0/modules/proxy/proxy_http.c
  
  Index: proxy_http.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_http.c,v
  retrieving revision 1.127
  retrieving revision 1.128
  diff -u -r1.127 -r1.128
  --- proxy_http.c	30 Jan 2002 18:46:56 -0000	1.127
  +++ proxy_http.c	1 Feb 2002 22:16:30 -0000	1.128
  @@ -428,10 +428,10 @@
                        "proxy: socket is connected");
   
           /* the socket is now open, create a new backend server connection */
  -        *origin = ap_new_connection(c->pool, r->server, p_conn->sock,
  -                                    r->connection->id, r->connection->sbh);
  +        *origin = ap_run_create_connection(c->pool, r->server, p_conn->sock,
  +                                           r->connection->id, r->connection->sbh);
           if (!origin) {
  -        /* the peer reset the connection already; ap_new_connection() 
  +        /* the peer reset the connection already; ap_run_create_connection() 
            * closed the socket
            */
               ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
  
  
  
  1.99      +6 -40     httpd-2.0/server/connection.c
  
  Index: connection.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/connection.c,v
  retrieving revision 1.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- connection.c	29 Jan 2002 19:02:03 -0000	1.98
  +++ connection.c	1 Feb 2002 22:16:30 -0000	1.99
  @@ -75,16 +75,18 @@
   #include "util_filter.h"
   
   APR_HOOK_STRUCT(
  -	    APR_HOOK_LINK(pre_connection)
  +            APR_HOOK_LINK(create_connection)
   	    APR_HOOK_LINK(process_connection)
               APR_HOOK_LINK(install_transport_filters)
  +	    APR_HOOK_LINK(pre_connection)
   )
  -
  -AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c),(c),OK,DECLINED)
  +AP_IMPLEMENT_HOOK_RUN_FIRST(conn_rec *,create_connection,
  +                            (apr_pool_t *p, server_rec *server, apr_socket_t *csd, long
conn_id, void *sbh),
  +                            (p, server, csd, conn_id, sbh), NULL)
   AP_IMPLEMENT_HOOK_RUN_FIRST(int,process_connection,(conn_rec *c),(c),DECLINED)
   AP_IMPLEMENT_HOOK_RUN_FIRST(int, install_transport_filters, 
                               (conn_rec *c, apr_socket_t *csd),(c, csd), DECLINED)
  -
  +AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c),(c),OK,DECLINED)
   /*
    * More machine-dependent networking gooo... on some systems,
    * you've got to be *really* sure that all the packets are acknowledged
  @@ -231,40 +233,4 @@
           ap_run_process_connection(c);
       }
   }
  -AP_CORE_DECLARE(conn_rec *)ap_new_connection(apr_pool_t *ptrans, server_rec *server, 
  -                                             apr_socket_t *csd, long id, void *sbh)
  -{
  -    apr_status_t rv;
  -    conn_rec *c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec));
   
  -    c->sbh = sbh; 
  -    (void) ap_update_child_status(c->sbh, SERVER_BUSY_READ, (request_rec *) NULL);
  -
  -    /* Got a connection structure, so initialize what fields we can
  -     * (the rest are zeroed out by pcalloc).
  -     */
  -    c->conn_config=ap_create_conn_config(ptrans);
  -    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;
  -    return c;
  -}
  
  
  
  1.142     +44 -0     httpd-2.0/server/core.c
  
  Index: core.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/core.c,v
  retrieving revision 1.141
  retrieving revision 1.142
  diff -u -r1.141 -r1.142
  --- core.c	30 Jan 2002 01:57:53 -0000	1.141
  +++ core.c	1 Feb 2002 22:16:30 -0000	1.142
  @@ -3614,7 +3614,43 @@
   {
       return core_create_req(pr);
   }
  +static conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *server,
  +                                  apr_socket_t *csd, long id, void *sbh)
  +{
  +    apr_status_t rv;
  +    conn_rec *c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec));
  +
  +    c->sbh = sbh; 
  +    (void) ap_update_child_status(c->sbh, SERVER_BUSY_READ, (request_rec *) NULL);
   
  +    /* Got a connection structure, so initialize what fields we can
  +     * (the rest are zeroed out by pcalloc).
  +     */
  +    c->conn_config=ap_create_conn_config(ptrans);
  +    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;
  +    return c;
  +}
   static int core_install_transport_filters(conn_rec *c, apr_socket_t *csd)
   {
       core_net_rec *net = apr_palloc(c->pool, sizeof(*net));
  @@ -3640,8 +3676,14 @@
   
   static void register_hooks(apr_pool_t *p)
   {
  +    /* create_connection and install_transport_filters are RUN_FIRST
  +     * hooks that should always be APR_HOOK_REALLY_LAST to give other 
  +     * modules the opportunity to install alternate network transports
  +     */
  +    ap_hook_create_connection(core_create_conn, NULL, NULL, APR_HOOK_REALLY_LAST);
       ap_hook_install_transport_filters(core_install_transport_filters, NULL, 
                                         NULL, APR_HOOK_REALLY_LAST);
  +
       ap_hook_post_config(core_post_config,NULL,NULL,APR_HOOK_REALLY_FIRST);
       ap_hook_translate_name(ap_core_translate,NULL,NULL,APR_HOOK_REALLY_LAST);
       ap_hook_map_to_storage(core_map_to_storage,NULL,NULL,APR_HOOK_REALLY_LAST);
  @@ -3689,3 +3731,5 @@
       core_cmds,			/* command apr_table_t */
       register_hooks		/* register hooks */
   };
  +
  +
  
  
  
  1.83      +1 -1      httpd-2.0/server/mpm/beos/beos.c
  
  Index: beos.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/beos/beos.c,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- beos.c	29 Jan 2002 19:02:03 -0000	1.82
  +++ beos.c	1 Feb 2002 22:16:31 -0000	1.83
  @@ -346,7 +346,7 @@
       }
   
       ap_create_sb_handle(&sbh, p, 0, my_child_num);
  -    current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id, sbh);
  +    current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id, sbh);
   
       if (current_conn) {
           ap_process_connection(current_conn, sock);
  
  
  
  1.15      +1 -1      httpd-2.0/server/mpm/mpmt_os2/mpmt_os2_child.c
  
  Index: mpmt_os2_child.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/mpmt_os2/mpmt_os2_child.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- mpmt_os2_child.c	29 Jan 2002 19:02:03 -0000	1.14
  +++ mpmt_os2_child.c	1 Feb 2002 22:16:31 -0000	1.15
  @@ -430,7 +430,7 @@
              rc == 0 && rd.ulData != WORKTYPE_EXIT) {
           pconn = worker_args->pconn;
           ap_create_sb_handle(&sbh, pconn, child_slot, thread_slot);
  -        current_conn = ap_new_connection(pconn, ap_server_conf, worker_args->conn_sd,
conn_id, sbh);
  +        current_conn = ap_run_create_connection(pconn, ap_server_conf, worker_args->conn_sd,
conn_id, sbh);
   
           if (current_conn) {
               ap_process_connection(current_conn, worker_args->conn_sd);
  
  
  
  1.31      +2 -2      httpd-2.0/server/mpm/netware/mpm_netware.c
  
  Index: mpm_netware.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/netware/mpm_netware.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- mpm_netware.c	1 Feb 2002 17:29:27 -0000	1.30
  +++ mpm_netware.c	1 Feb 2002 22:16:31 -0000	1.31
  @@ -525,8 +525,8 @@
           * We now have a connection, so set it up with the appropriate
           * socket options, file descriptors, and read/write buffers.
           */
  -        current_conn = ap_new_connection(ptrans, ap_server_conf, csd, 
  -                                         my_worker_num, sbh);
  +        current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd, 
  +                                                my_worker_num, sbh);
           if (current_conn) {
               ap_process_connection(current_conn, csd);
               ap_lingering_close(current_conn);
  
  
  
  1.106     +1 -1      httpd-2.0/server/mpm/perchild/perchild.c
  
  Index: perchild.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/perchild/perchild.c,v
  retrieving revision 1.105
  retrieving revision 1.106
  diff -u -r1.105 -r1.106
  --- perchild.c	29 Jan 2002 19:02:03 -0000	1.105
  +++ perchild.c	1 Feb 2002 22:16:31 -0000	1.106
  @@ -567,7 +567,7 @@
       }
   
       ap_create_sb_handle(&sbh, p, conn_id / thread_limit, thread_num);
  -    current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id, sbh);
  +    current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id, sbh);
       if (current_conn) {
           ap_process_connection(current_conn, sock);
           ap_lingering_close(current_conn);
  
  
  
  1.237     +1 -1      httpd-2.0/server/mpm/prefork/prefork.c
  
  Index: prefork.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/prefork.c,v
  retrieving revision 1.236
  retrieving revision 1.237
  diff -u -r1.236 -r1.237
  --- prefork.c	30 Jan 2002 22:35:56 -0000	1.236
  +++ prefork.c	1 Feb 2002 22:16:31 -0000	1.237
  @@ -712,7 +712,7 @@
   	 * socket options, file descriptors, and read/write buffers.
   	 */
   
  -	current_conn = ap_new_connection(ptrans, ap_server_conf, csd, my_child_num, sbh);
  +	current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd, my_child_num, sbh);
           if (current_conn) {
               ap_process_connection(current_conn, csd);
               ap_lingering_close(current_conn);
  
  
  
  1.215     +5 -5      httpd-2.0/server/mpm/winnt/mpm_winnt.c
  
  Index: mpm_winnt.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/mpm_winnt.c,v
  retrieving revision 1.214
  retrieving revision 1.215
  diff -u -r1.214 -r1.215
  --- mpm_winnt.c	30 Jan 2002 22:35:57 -0000	1.214
  +++ mpm_winnt.c	1 Feb 2002 22:16:31 -0000	1.215
  @@ -897,7 +897,7 @@
    * Main entry point for the worker threads. Worker threads block in 
    * win*_get_connection() awaiting a connection to service.
    */
  -static void worker_main(int thread_num)
  +static void worker_main(long thread_num)
   {
       static int requests_this_child = 0;
       PCOMP_CONTEXT context = NULL;
  @@ -941,8 +941,8 @@
           apr_os_sock_make(&context->sock, &sockinfo, context->ptrans);
   
           ap_create_sb_handle(&sbh, context->ptrans, 0, thread_num);
  -        c = ap_new_connection(context->ptrans, ap_server_conf, context->sock,
  -                              thread_num, sbh);
  +        c = ap_run_create_connection(context->ptrans, ap_server_conf, context->sock,
  +                                     thread_num, sbh);
   
           if (c) {
               ap_process_connection(c, context->sock);
  @@ -953,7 +953,7 @@
               }
           }
           else {
  -            /* ap_new_connection closes the socket on failure */
  +            /* ap_run_create_connection closes the socket on failure */
               context->accept_socket = INVALID_SOCKET;
           }
       }
  @@ -1014,7 +1014,7 @@
                        "Child %d: exit_event_name = %s", my_pid, exit_event_name);
           /* Set up the scoreboard. */
           ap_my_generation = atoi(getenv("AP_MY_GENERATION"));
  -    ap_log_error(APLOG_MARK, APLOG_CRIT, APR_SUCCESS, ap_server_conf,
  +        ap_log_error(APLOG_MARK, APLOG_CRIT, APR_SUCCESS, ap_server_conf,
                        "getting listeners child_main", my_pid);        
           get_listeners_from_parent(ap_server_conf);
       }
  
  
  
  1.70      +1 -1      httpd-2.0/server/mpm/worker/worker.c
  
  Index: worker.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/worker/worker.c,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- worker.c	30 Jan 2002 22:35:57 -0000	1.69
  +++ worker.c	1 Feb 2002 22:16:31 -0000	1.70
  @@ -554,7 +554,7 @@
           return;
       }
   
  -    current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id, sbh);
  +    current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id, sbh);
       if (current_conn) {
           ap_process_connection(current_conn, sock);
           ap_lingering_close(current_conn);
  
  
  

Mime
View raw message