From: Graham Leggett Date: Sat, 17 Feb 2018 21:39:53 +0000 (+0000) Subject: core: Create a conn_config_t structure to hold an extendable core config rather X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b92ff77a749ba0ea5a6a6894ba111d69a72084a;p=apache core: Create a conn_config_t structure to hold an extendable core config rather than consuming the whole pointer with the connection socket. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1824635 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 8a8e30708a..31fa309f75 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.1 + *) core: Create a conn_config_t structure to hold an extendable core config rather + than consuming the whole pointer with the connection socket. [Graham Leggett] + *) mpm_event: Do lingering close in worker(s). [Yann Ylavic] *) mpm_queue: Put fdqueue code in common for MPMs event and worker. diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 6a13f80ff5..21bb75af70 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -568,6 +568,7 @@ * 20171014.6 (2.5.1-dev) Add AP_REG_DOLLAR_ENDONLY, ap_regcomp_get_default_cflags * ap_regcomp_set_default_cflags and * ap_regcomp_default_cflag_by_name + * 20171014.7 (2.5.1-dev) Add AP_CORE_DEFAULT macro */ #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */ @@ -575,7 +576,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20171014 #endif -#define MODULE_MAGIC_NUMBER_MINOR 6 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 7 /* 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 e99816da81..d8e305835a 100644 --- a/include/http_core.h +++ b/include/http_core.h @@ -1112,6 +1112,11 @@ AP_DECLARE(int) ap_state_query(int query_code); */ AP_CORE_DECLARE(conn_rec *) ap_create_slave_connection(conn_rec *c); + +/** Macro to provide a default value if the pointer is not yet initialised + */ +#define AP_CORE_DEFAULT(X, Y, Z) (X ? X->Y : Z) + #ifdef __cplusplus } #endif diff --git a/server/Makefile.in b/server/Makefile.in index 00c3e55fd5..71aea62056 100644 --- a/server/Makefile.in +++ b/server/Makefile.in @@ -68,6 +68,7 @@ export_files: ( for dir in $(EXPORT_DIRS); do \ ls $$dir/*.h ; \ done; \ + echo "$(top_srcdir)/server/core.h"; \ echo "$(top_srcdir)/server/mpm_fdqueue.h"; \ for dir in $(EXPORT_DIRS_APR); do \ ls $$dir/ap[ru].h $$dir/ap[ru]_*.h 2>/dev/null; \ diff --git a/server/core.c b/server/core.c index c7d137b585..d69ca37350 100644 --- a/server/core.c +++ b/server/core.c @@ -50,6 +50,7 @@ #include "ap_listen.h" #include "ap_provider.h" #include "ap_regex.h" +#include "core.h" #include "mod_so.h" /* for ap_find_loaded_module_symbol */ @@ -5231,7 +5232,9 @@ AP_DECLARE(void **) ap_get_request_note(request_rec *r, apr_size_t note_num) AP_DECLARE(apr_socket_t *) ap_get_conn_socket(conn_rec *c) { - return ap_get_core_module_config(c->conn_config); + conn_config_t *conn_config = ap_get_core_module_config(c->conn_config); + + return AP_CORE_DEFAULT(conn_config, socket, NULL); } static int core_create_req(request_rec *r) @@ -5344,6 +5347,7 @@ static conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *s, static int core_pre_connection(conn_rec *c, void *csd) { core_net_rec *net; + conn_config_t *conn_config; apr_status_t rv; if (c->master) { @@ -5385,7 +5389,10 @@ static int core_pre_connection(conn_rec *c, void *csd) net->out_ctx = NULL; net->client_socket = csd; - ap_set_core_module_config(net->c->conn_config, csd); + conn_config = apr_palloc(c->pool, sizeof(conn_config)); + conn_config->socket = csd; + ap_set_core_module_config(net->c->conn_config, conn_config); + /* only the master connection talks to the network */ if (c->master == NULL) { ap_add_input_filter_handle(ap_core_input_filter_handle, net, NULL, diff --git a/server/core.h b/server/core.h new file mode 100644 index 0000000000..a4ef1cfeb9 --- /dev/null +++ b/server/core.h @@ -0,0 +1,39 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file server/core.h + * @brief core private declarations + * + * @addtogroup APACHE_CORE + * @{ + */ + +#ifndef CORE_H +#define CORE_H + +/** + * @brief A structure to contain connection state information + */ +typedef struct conn_config_t { + /** Socket belonging to the connection */ + apr_socket_t *socket; +} conn_config_t; + + +#endif /* CORE_H */ +/** @} */ +