Commit 7a0b2a36 authored by Ryan Bloom's avatar Ryan Bloom
Browse files

Cleanup some code that was created during the abstration. This basically

takes the old ap_new_connection, and puts into the new core_create_conn
function.  There is no good reason to have two functions to do this.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91890 13f79535-47bb-0310-9956-ffa450edef68
parent 552bcb80
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -131,15 +131,7 @@ AP_DECLARE_HOOK(int,process_connection,(conn_rec *c))
/**
 */
AP_DECLARE_HOOK(conn_rec *, create_connection,
                (apr_pool_t *p, apr_socket_t *csd, int child_num))

/* This is NOT staying here.  It is necessary to quiet warnings
 * while I would on the next patch. rbb
 */

AP_CORE_DECLARE(conn_rec *)ap_core_new_connection(apr_pool_t *p,
                            server_rec *server, apr_socket_t *inout,
                            core_net_rec *net, long id);
                (apr_pool_t *p, apr_socket_t *csd, int conn_ed))

#ifdef __cplusplus
}
+2 −50
Original line number Diff line number Diff line
@@ -82,8 +82,8 @@ APR_HOOK_STRUCT(
AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c),(c),OK,DECLINED)
AP_IMPLEMENT_HOOK_RUN_FIRST(int,process_connection,(conn_rec *c),(c),DECLINED)
AP_IMPLEMENT_HOOK_RUN_FIRST(conn_rec *,create_connection,
                     (apr_pool_t *p, apr_socket_t *csd, int my_child_num),
                     (p, csd, my_child_num), NULL)
                     (apr_pool_t *p, apr_socket_t *csd, int conn_id),
                     (p, csd, conn_id), NULL)

/*
 * More machine-dependent networking gooo... on some systems,
@@ -222,51 +222,3 @@ AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c)
    ap_run_process_connection(c);

}

/* Clearly some of this stuff doesn't belong in a generalised connection
   structure, but for now...
*/

AP_CORE_DECLARE(conn_rec *)ap_core_new_connection(apr_pool_t *p, 
                            server_rec *server, apr_socket_t *inout, 
                            core_net_rec *net, long id)
{
    conn_rec *conn = (conn_rec *) apr_pcalloc(p, sizeof(conn_rec));
    apr_status_t rv;

    (void) ap_update_child_status(AP_CHILD_THREAD_FROM_ID(id), 
                                  SERVER_BUSY_READ, (request_rec *) NULL);

    /* Got a connection structure, so initialize what fields we can
     * (the rest are zeroed out by pcalloc).
     */

    conn->conn_config=ap_create_conn_config(p);
    conn->notes = apr_table_make(p, 5);

    conn->pool = p;
    if ((rv = apr_socket_addr_get(&conn->local_addr, APR_LOCAL, inout)) 
        != APR_SUCCESS) {
        ap_log_error(APLOG_MARK, APLOG_INFO, rv, server,
                     "apr_socket_addr_get(APR_LOCAL)");
        apr_socket_close(inout);
        return NULL;
    }
    apr_sockaddr_ip_get(&conn->local_ip, conn->local_addr);
    if ((rv = apr_socket_addr_get(&conn->remote_addr, APR_REMOTE, inout))
        != APR_SUCCESS) {
        ap_log_error(APLOG_MARK, APLOG_INFO, rv, server,
                     "apr_socket_addr_get(APR_REMOTE)");
        apr_socket_close(inout);
        return NULL;
    }
    apr_sockaddr_ip_get(&conn->remote_ip, conn->remote_addr);
    conn->base_server = server;
    net->client_socket = inout;

    conn->id = id;

    apr_pool_cleanup_register(p, net, ap_lingering_close, apr_pool_cleanup_null);

    return conn;
}
+38 −4
Original line number Diff line number Diff line
@@ -3277,9 +3277,10 @@ static int core_create_proxy_req(request_rec *r, request_rec *pr)
}

static conn_rec *core_create_conn(apr_pool_t *ptrans, apr_socket_t *csd,
                                  int my_child_num)
                                  int conn_id)
{
    core_net_rec *net = apr_palloc(ptrans, sizeof(*net));
    apr_status_t rv;

#ifdef AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
    ap_sock_disable_nagle(csd);
@@ -3287,8 +3288,41 @@ static conn_rec *core_create_conn(apr_pool_t *ptrans, apr_socket_t *csd,

    net->in_ctx = NULL;
    net->out_ctx = NULL;
    net->c = ap_core_new_connection(ptrans, ap_server_conf, csd,
                                    net, my_child_num);
    net->c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec));
 
    (void) ap_update_child_status(AP_CHILD_THREAD_FROM_ID(conn_id),
                                  SERVER_BUSY_READ, (request_rec *) NULL);
 
    /* Got a connection structure, so initialize what fields we can
     * (the rest are zeroed out by pcalloc).
     */
 
    net->c->conn_config=ap_create_conn_config(ptrans);
    net->c->notes = apr_table_make(ptrans, 5);
 
    net->c->pool = ptrans;
    if ((rv = apr_socket_addr_get(&net->c->local_addr, APR_LOCAL, csd))
        != APR_SUCCESS) {
        ap_log_error(APLOG_MARK, APLOG_INFO, rv, ap_server_conf,
                     "apr_socket_addr_get(APR_LOCAL)");
        apr_socket_close(csd);
        return NULL;
    }
    apr_sockaddr_ip_get(&net->c->local_ip, net->c->local_addr);
    if ((rv = apr_socket_addr_get(&net->c->remote_addr, APR_REMOTE, csd))
        != APR_SUCCESS) {
        ap_log_error(APLOG_MARK, APLOG_INFO, rv, ap_server_conf,
                     "apr_socket_addr_get(APR_REMOTE)");
        apr_socket_close(csd);
        return NULL;
    }
    apr_sockaddr_ip_get(&net->c->remote_ip, net->c->remote_addr);
    net->c->base_server = ap_server_conf;
    net->client_socket = csd;
 
    net->c->id = conn_id;
 
    apr_pool_cleanup_register(ptrans, net, ap_lingering_close, apr_pool_cleanup_null);
 
    ap_add_input_filter("CORE_IN", net, NULL, net->c);
    ap_add_output_filter("CORE", net, NULL, net->c);