| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: app.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ | | 1 | /* $NetBSD: app.c,v 1.5 2019/12/29 01:38:27 christos Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (C) Internet Systems Consortium, Inc. ("ISC") | | 4 | * Copyright (C) Internet Systems Consortium, Inc. ("ISC") |
5 | * | | 5 | * |
6 | * This Source Code Form is subject to the terms of the Mozilla Public | | 6 | * This Source Code Form is subject to the terms of the Mozilla Public |
7 | * License, v. 2.0. If a copy of the MPL was not distributed with this | | 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | | 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
9 | * | | 9 | * |
10 | * See the COPYRIGHT file distributed with this work for additional | | 10 | * See the COPYRIGHT file distributed with this work for additional |
11 | * information regarding copyright ownership. | | 11 | * information regarding copyright ownership. |
12 | */ | | 12 | */ |
13 | | | 13 | |
14 | /*! \file */ | | 14 | /*! \file */ |
| @@ -186,26 +186,27 @@ isc_app_ctxstart(isc_appctx_t *ctx0) { | | | @@ -186,26 +186,27 @@ isc_app_ctxstart(isc_appctx_t *ctx0) { |
186 | result = handle_signal(SIGHUP, SIG_DFL); | | 186 | result = handle_signal(SIGHUP, SIG_DFL); |
187 | if (result != ISC_R_SUCCESS) | | 187 | if (result != ISC_R_SUCCESS) |
188 | goto cleanup; | | 188 | goto cleanup; |
189 | | | 189 | |
190 | #ifdef HAVE_SIGWAIT | | 190 | #ifdef HAVE_SIGWAIT |
191 | result = handle_signal(SIGTERM, SIG_DFL); | | 191 | result = handle_signal(SIGTERM, SIG_DFL); |
192 | if (result != ISC_R_SUCCESS) | | 192 | if (result != ISC_R_SUCCESS) |
193 | goto cleanup; | | 193 | goto cleanup; |
194 | result = handle_signal(SIGINT, SIG_DFL); | | 194 | result = handle_signal(SIGINT, SIG_DFL); |
195 | if (result != ISC_R_SUCCESS) | | 195 | if (result != ISC_R_SUCCESS) |
196 | goto cleanup; | | 196 | goto cleanup; |
197 | #endif | | 197 | #endif |
198 | | | 198 | |
| | | 199 | if (isc_bind9) { |
199 | /* | | 200 | /* |
200 | * Block SIGHUP, SIGINT, SIGTERM. | | 201 | * Block SIGHUP, SIGINT, SIGTERM. |
201 | * | | 202 | * |
202 | * If isc_app_start() is called from the main thread before any other | | 203 | * If isc_app_start() is called from the main thread before any other |
203 | * threads have been created, then the pthread_sigmask() call below | | 204 | * threads have been created, then the pthread_sigmask() call below |
204 | * will result in all threads having SIGHUP, SIGINT and SIGTERM | | 205 | * will result in all threads having SIGHUP, SIGINT and SIGTERM |
205 | * blocked by default, ensuring that only the thread that calls | | 206 | * blocked by default, ensuring that only the thread that calls |
206 | * sigwait() for them will get those signals. | | 207 | * sigwait() for them will get those signals. |
207 | */ | | 208 | */ |
208 | if (sigemptyset(&sset) != 0 || | | 209 | if (sigemptyset(&sset) != 0 || |
209 | sigaddset(&sset, SIGHUP) != 0 || | | 210 | sigaddset(&sset, SIGHUP) != 0 || |
210 | sigaddset(&sset, SIGINT) != 0 || | | 211 | sigaddset(&sset, SIGINT) != 0 || |
211 | sigaddset(&sset, SIGTERM) != 0) { | | 212 | sigaddset(&sset, SIGTERM) != 0) { |
| @@ -214,26 +215,27 @@ isc_app_ctxstart(isc_appctx_t *ctx0) { | | | @@ -214,26 +215,27 @@ isc_app_ctxstart(isc_appctx_t *ctx0) { |
214 | "isc_app_start() sigsetops: %s", strbuf); | | 215 | "isc_app_start() sigsetops: %s", strbuf); |
215 | result = ISC_R_UNEXPECTED; | | 216 | result = ISC_R_UNEXPECTED; |
216 | goto cleanup; | | 217 | goto cleanup; |
217 | } | | 218 | } |
218 | presult = pthread_sigmask(SIG_BLOCK, &sset, NULL); | | 219 | presult = pthread_sigmask(SIG_BLOCK, &sset, NULL); |
219 | if (presult != 0) { | | 220 | if (presult != 0) { |
220 | strerror_r(presult, strbuf, sizeof(strbuf)); | | 221 | strerror_r(presult, strbuf, sizeof(strbuf)); |
221 | UNEXPECTED_ERROR(__FILE__, __LINE__, | | 222 | UNEXPECTED_ERROR(__FILE__, __LINE__, |
222 | "isc_app_start() pthread_sigmask: %s", | | 223 | "isc_app_start() pthread_sigmask: %s", |
223 | strbuf); | | 224 | strbuf); |
224 | result = ISC_R_UNEXPECTED; | | 225 | result = ISC_R_UNEXPECTED; |
225 | goto cleanup; | | 226 | goto cleanup; |
226 | } | | 227 | } |
| | | 228 | } |
227 | | | 229 | |
228 | return (ISC_R_SUCCESS); | | 230 | return (ISC_R_SUCCESS); |
229 | | | 231 | |
230 | cleanup: | | 232 | cleanup: |
231 | (void)isc_condition_destroy(&ctx->ready); | | 233 | (void)isc_condition_destroy(&ctx->ready); |
232 | (void)isc_mutex_destroy(&ctx->readylock); | | 234 | (void)isc_mutex_destroy(&ctx->readylock); |
233 | return (result); | | 235 | return (result); |
234 | } | | 236 | } |
235 | | | 237 | |
236 | isc_result_t | | 238 | isc_result_t |
237 | isc_app_start(void) { | | 239 | isc_app_start(void) { |
238 | isc_g_appctx.common.impmagic = APPCTX_MAGIC; | | 240 | isc_g_appctx.common.impmagic = APPCTX_MAGIC; |
239 | isc_g_appctx.common.magic = ISCAPI_APPCTX_MAGIC; | | 241 | isc_g_appctx.common.magic = ISCAPI_APPCTX_MAGIC; |