63 lines
1.6 KiB
Diff
63 lines
1.6 KiB
Diff
From bcfbc17384125d328a0f9ab70057cb6540b134c7 Mon Sep 17 00:00:00 2001
|
|
From: Mark Andrews <marka@isc.org>
|
|
Date: Fri, 21 Aug 2020 14:05:21 +1000
|
|
Subject: [PATCH] Lock access to ctx->blocked as it is updated by multiple
|
|
threads
|
|
|
|
Conflict: NA
|
|
Reference: https://gitlab.isc.org/isc-projects/bind9/-/commit/bcfbc17384125d328a0f9ab70057cb6540b134c7
|
|
---
|
|
lib/isc/unix/app.c | 13 ++++++++++++-
|
|
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/lib/isc/unix/app.c b/lib/isc/unix/app.c
|
|
index 567f300195..dd7d0e8746 100644
|
|
--- a/lib/isc/unix/app.c
|
|
+++ b/lib/isc/unix/app.c
|
|
@@ -743,8 +743,12 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
|
|
return (ISC_R_RELOAD);
|
|
}
|
|
|
|
- if (ctx->want_shutdown && ctx->blocked)
|
|
+ LOCK(&ctx->lock);
|
|
+ if (ctx->want_shutdown && ctx->blocked) {
|
|
+ UNLOCK(&ctx->lock);
|
|
exit(1);
|
|
+ }
|
|
+ UNLOCK(&ctx->lock);
|
|
}
|
|
|
|
return (ISC_R_SUCCESS);
|
|
@@ -930,10 +934,14 @@ isc__app_block(void) {
|
|
#ifdef ISC_PLATFORM_USETHREADS
|
|
sigset_t sset;
|
|
#endif /* ISC_PLATFORM_USETHREADS */
|
|
+
|
|
+ LOCK(&isc_g_appctx.lock);
|
|
+
|
|
REQUIRE(isc_g_appctx.running);
|
|
REQUIRE(!isc_g_appctx.blocked);
|
|
|
|
isc_g_appctx.blocked = true;
|
|
+ UNLOCK(&isc_g_appctx.lock);
|
|
#ifdef ISC_PLATFORM_USETHREADS
|
|
blockedthread = pthread_self();
|
|
RUNTIME_CHECK(sigemptyset(&sset) == 0 &&
|
|
@@ -949,10 +957,13 @@ isc__app_unblock(void) {
|
|
sigset_t sset;
|
|
#endif /* ISC_PLATFORM_USETHREADS */
|
|
|
|
+ LOCK(&isc_g_appctx.lock);
|
|
+
|
|
REQUIRE(isc_g_appctx.running);
|
|
REQUIRE(isc_g_appctx.blocked);
|
|
|
|
isc_g_appctx.blocked = false;
|
|
+ UNLOCK(&isc_g_appctx.lock);
|
|
|
|
#ifdef ISC_PLATFORM_USETHREADS
|
|
REQUIRE(blockedthread == pthread_self());
|
|
--
|
|
2.23.0
|
|
|