From: Jim Jagielski Date: Fri, 7 Feb 2014 13:54:38 +0000 (+0000) Subject: Add in the concept of "slave" connections... X-Git-Tag: 2.5.0-alpha~4505 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b1225679551516d5e6d41cec77be982e2bb36805;p=apache Add in the concept of "slave" connections... Allows for several "connections" all resulting in a single real connection that talks to the network. Right now, nothing uses this though. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1565657 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 06eb663dab..c7e4467247 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -447,14 +447,15 @@ * 20131230.0 (2.5.0-dev) cl_head_zero & expect_strict added to server_config * 20131230.1 (2.5.0-dev) REWRITE_REDIRECT_HANDLER_NAME in mod_rewrite.h * 20131230.2 (2.5.0-dev) Prefix REWRITE_REDIRECT_HANDLER_NAME in mod_rewrite.h + * 20140207.0 (2.5.0-dev) Support for slaved connections in core.c */ #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */ #ifndef MODULE_MAGIC_NUMBER_MAJOR -#define MODULE_MAGIC_NUMBER_MAJOR 20131230 +#define MODULE_MAGIC_NUMBER_MAJOR 20140207 #endif -#define MODULE_MAGIC_NUMBER_MINOR 2 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/http_core.h b/include/http_core.h index 47cd98fb45..337859ba05 100644 --- a/include/http_core.h +++ b/include/http_core.h @@ -1036,6 +1036,15 @@ AP_DECLARE(int) ap_state_query(int query_code); /** only dump some parts of the config */ #define AP_SQ_RM_CONFIG_DUMP 4 + +/* ---------------------------------------------------------------------- */ + +/** Create a slave connection + * @param c The connection to create the slave connection from/for + * @return The slave connection + */ +AP_CORE_DECLARE(conn_rec *) ap_create_slave_connection(conn_rec *c); + #ifdef __cplusplus } #endif diff --git a/include/httpd.h b/include/httpd.h index 0333c01d5f..228b81f172 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -753,6 +753,8 @@ typedef struct process_rec process_rec; typedef struct server_rec server_rec; /** A structure that represents one connection */ typedef struct conn_rec conn_rec; +/** A structure that represents one slave connection */ +typedef struct conn_slave_rec conn_slave_rec; /** A structure that represents the current request */ typedef struct request_rec request_rec; /** A structure that represents the status of the current connection */ @@ -1162,6 +1164,19 @@ struct conn_rec { #if APR_HAS_THREADS apr_thread_t *current_thread; #endif + + /** Array of slave connections (conn_slave_rec *) for this connection. */ + apr_array_header_t *slaves; + + /** The "real" master connection. NULL if I am the master. */ + conn_rec *master; + + /** context of this connection */ + void *ctx; +}; + +struct conn_slave_rec { + conn_rec *c; }; /** diff --git a/server/connection.c b/server/connection.c index 6e4495f838..fd878df54e 100644 --- a/server/connection.c +++ b/server/connection.c @@ -202,4 +202,3 @@ AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c, void *csd) ap_run_process_connection(c); } } - diff --git a/server/core.c b/server/core.c index ff7c43dce0..950f33697d 100644 --- a/server/core.c +++ b/server/core.c @@ -4832,6 +4832,7 @@ static conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *s, apr_bucket_alloc_t *alloc) { apr_status_t rv; + apr_pool_t *pool; conn_rec *c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec)); core_server_config *sconf = ap_get_core_module_config(s->module_config); @@ -4841,10 +4842,15 @@ static conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *s, /* 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); + apr_pool_create(&pool, ptrans); + apr_pool_tag(pool, "master_conn"); + c->pool = pool; + + c->conn_config = ap_create_conn_config(c->pool); + c->notes = apr_table_make(c->pool, 5); + c->slaves = apr_array_make(c->pool, 20, sizeof(conn_rec *)); + - 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, s, APLOGNO(00137) @@ -4931,11 +4937,35 @@ static int core_pre_connection(conn_rec *c, void *csd) net->client_socket = csd; ap_set_core_module_config(net->c->conn_config, csd); - ap_add_input_filter_handle(ap_core_input_filter_handle, net, NULL, net->c); - ap_add_output_filter_handle(ap_core_output_filter_handle, net, NULL, net->c); + /* only the master connection talks to the network */ + if (c->master == NULL) { + ap_add_input_filter_handle(ap_core_input_filter_handle, net, NULL, + net->c); + ap_add_output_filter_handle(ap_core_output_filter_handle, net, NULL, + net->c); + } return DONE; } +AP_CORE_DECLARE(conn_rec *) ap_create_slave_connection(conn_rec *c) +{ + apr_pool_t *pool; + conn_slave_rec *new; + conn_rec *sc = (conn_rec *) apr_palloc(c->pool, sizeof(conn_rec)); + + apr_pool_create(&pool, c->pool); + apr_pool_tag(pool, "slave_conn"); + memcpy(sc, c, sizeof(conn_rec)); + sc->slaves = NULL; + sc->master = c; + sc->input_filters = NULL; + sc->output_filters = NULL; + sc->pool = pool; + new = apr_array_push(c->slaves); + new->c = sc; + return sc; +} + AP_DECLARE(int) ap_state_query(int query) { switch (query) {