Permalink
Browse files

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
  • Loading branch information...
jimjag committed Feb 7, 2014
1 parent f0dea5c commit 8d9cdb307a76c3f854fa144df3e6dfce3787937e
Showing with 62 additions and 8 deletions.
  1. +3 −2 include/ap_mmn.h
  2. +9 −0 include/http_core.h
  3. +15 −0 include/httpd.h
  4. +0 −1 server/connection.c
  5. +35 −5 server/core.c
View
@@ -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
View
@@ -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
View
@@ -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;
};
/**
View
@@ -202,4 +202,3 @@ AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c, void *csd)
ap_run_process_connection(c);
}
}
-
View
@@ -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) {

0 comments on commit 8d9cdb3

Please sign in to comment.