]> granicus.if.org Git - apache/commitdiff
core: Create a conn_config_t structure to hold an extendable core config rather
authorGraham Leggett <minfrin@apache.org>
Sat, 17 Feb 2018 21:39:53 +0000 (21:39 +0000)
committerGraham Leggett <minfrin@apache.org>
Sat, 17 Feb 2018 21:39:53 +0000 (21:39 +0000)
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

CHANGES
include/ap_mmn.h
include/http_core.h
server/Makefile.in
server/core.c
server/core.h [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index 8a8e30708af9e335394c4e184dfe1cc9b06c3452..31fa309f7517e62604aaac0217731e7edf41118c 100644 (file)
--- 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.
index 6a13f80ff567c99c9003324b34cb9ab6971f6ba5..21bb75af70d123b7637eab20a98aba7cd07ba228 100644 (file)
  * 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" */
 #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
index e99816da81639ffd38049795180dffa97998a6e1..d8e305835af0d13acf3ab256df736a9afa0a4138 100644 (file)
@@ -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
index 00c3e55fd51c009b387c96384f5d541ee5db79cf..71aea62056aeb2a8b30c554c067684a1d1ca9f68 100644 (file)
@@ -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; \
index c7d137b5856aa0c4ac0e03aa7cc62eae833361db..d69ca37350dc08556f541f0d80921e7ceb176e53 100644 (file)
@@ -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 (file)
index 0000000..a4ef1cf
--- /dev/null
@@ -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 */
+/** @} */
+