]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* mod_http2: when a server is restarted gracefully, any idle h2 worker
authorStefan Eissing <icing@apache.org>
Fri, 10 Sep 2021 08:14:48 +0000 (08:14 +0000)
committerStefan Eissing <icing@apache.org>
Fri, 10 Sep 2021 08:14:48 +0000 (08:14 +0000)
    threads are shut down immediately. [Stefan Eissing]

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1893214 13f79535-47bb-0310-9956-ffa450edef68

changes-entries/http2_graceful.txt [new file with mode: 0644]
modules/http2/h2_conn.c
modules/http2/h2_conn.h
modules/http2/h2_session.c
modules/http2/h2_task.c
modules/http2/h2_util.c
modules/http2/h2_version.h
modules/http2/h2_workers.c
modules/http2/h2_workers.h
modules/http2/mod_http2.c

diff --git a/changes-entries/http2_graceful.txt b/changes-entries/http2_graceful.txt
new file mode 100644 (file)
index 0000000..dc57195
--- /dev/null
@@ -0,0 +1,4 @@
+  * mod_http2: when a server is restarted gracefully, any idle h2 worker
+    threads are shut down immediately. [Stefan Eissing]
+
+
index 7d539c540c8126b7ff8b505c7d94511fa3089833..018d5819a78ce2ee9c2e8adb28251f5bc7ead95f 100644 (file)
@@ -148,6 +148,13 @@ apr_status_t h2_conn_child_init(apr_pool_t *pool, server_rec *s)
     return status;
 }
 
+void h2_conn_child_stopping(apr_pool_t *pool, int graceful)
+{
+    if (workers && graceful) {
+        h2_workers_graceful_shutdown(workers);
+    }
+}
+
 h2_mpm_type_t h2_conn_mpm_type(void)
 {
     check_modules(0);
index 3b8b33e3994f4822260ada3ef9428540dcb3ff71..de868cfa579b3d31a2336fa21bcb6726156bb851 100644 (file)
@@ -45,12 +45,17 @@ apr_status_t h2_conn_run(conn_rec *c);
  */
 apr_status_t h2_conn_pre_close(struct h2_ctx *ctx, conn_rec *c);
 
-/* Initialize this child process for h2 connection work,
+/**
+ * Initialize this child process for h2 connection work,
  * to be called once during child init before multi processing
  * starts.
  */
 apr_status_t h2_conn_child_init(apr_pool_t *pool, server_rec *s);
 
+/**
+ * Child is about to be stopped, release unused resources
+ */
+void h2_conn_child_stopping(apr_pool_t *pool, int graceful);
 
 typedef enum {
     H2_MPM_UNKNOWN,
index 453a98fd36c1fbac93a678b04fe78a58fe34a5db..3284aa2ff642c1bdadee6cf864d7e8911607eb82 100644 (file)
@@ -1912,7 +1912,9 @@ static void h2_session_ev_mpm_stopping(h2_session *session, int arg, const char
             break;
         default:
             h2_session_shutdown_notice(session);
+#if !AP_MODULE_MAGIC_AT_LEAST(20120211, 110)
             h2_workers_graceful_shutdown(session->workers);
+#endif
             break;
     }
 }
index 2ac6ea4735c78552b26c4f28ffa3fe7f3f78b428..5b32656a912d725657a34b35ce660e48f2170c9a 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 #include <assert.h>
 #include <stddef.h>
 
index c00a31c5ab156b42a0dbf259bdd683f9da7aa270..9b2b3de968250f974a35df50a5d5201cbdd341cf 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 #include <assert.h>
 #include <apr_strings.h>
 #include <apr_thread_mutex.h>
index 785a172386fd8c2c936a5a6033c8463167e432c7..664e63a0727046b87b9d683664b749fe6e93a334 100644 (file)
@@ -27,7 +27,7 @@
  * @macro
  * Version number of the http2 module as c string
  */
-#define MOD_HTTP2_VERSION "1.15.22"
+#define MOD_HTTP2_VERSION "1.15.23"
 
 /**
  * @macro
@@ -35,7 +35,7 @@
  * release. This is a 24 bit number with 8 bits for major number, 8 bits
  * for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203.
  */
-#define MOD_HTTP2_VERSION_NUM 0x010f16
+#define MOD_HTTP2_VERSION_NUM 0x010f17
 
 
 #endif /* mod_h2_h2_version_h */
index b3eca4285c3a497cb69e2c48837283149f11c92f..ceed4c6d5e18f9c2ce28f41f6ac9e9582636c869 100644 (file)
@@ -480,6 +480,8 @@ apr_status_t h2_workers_unregister(h2_workers *workers, struct h2_mplx *m)
 void h2_workers_graceful_shutdown(h2_workers *workers)
 {
     workers->shutdown = 1;
+    workers->min_workers = 1;
+    workers->max_idle_duration = apr_time_from_sec(1);
     h2_fifo_term(workers->mplxs);
     wake_non_essential_workers(workers);
 }
index cc310c9b75b8d4678d4f16d7b48cce61c96f56b7..2aa3b3a3b312fbb1a637050427592c8b3dc8b184 100644 (file)
@@ -38,9 +38,9 @@ struct h2_workers {
     apr_pool_t *pool;
     
     int next_worker_id;
-    apr_uint32_t min_workers;
     apr_uint32_t max_workers;
-    apr_interval_time_t max_idle_duration;
+    volatile apr_uint32_t min_workers; /* is changed during graceful shutdown */
+    volatile apr_interval_time_t max_idle_duration; /* is changed during graceful shutdown */
     
     volatile int aborted;
     volatile int shutdown;
index 24f1585725174ff0c61783cfd14b1372d96ace6c..3f2a61fc3eda4566322c5ed2dcb5da9465e3765e 100644 (file)
@@ -24,6 +24,7 @@
 #include <http_protocol.h>
 #include <http_request.h>
 #include <http_log.h>
+#include <mpm_common.h>
 
 #include "mod_http2.h"
 
@@ -228,7 +229,9 @@ static void h2_hooks(apr_pool_t *pool)
     /* Run once after a child process has been created.
      */
     ap_hook_child_init(h2_child_init, NULL, NULL, APR_HOOK_MIDDLE);
-
+#if AP_MODULE_MAGIC_AT_LEAST(20120211, 110)
+    ap_hook_child_stopping(h2_conn_child_stopping, NULL, NULL, APR_HOOK_MIDDLE);
+#endif
     h2_h2_register_hooks();
     h2_switch_register_hooks();
     h2_task_register_hooks();