* 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
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 */
#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;
};
/**
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);
/* 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)
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) {