]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] prevent exportlib deadlock
authorEvan Hunt <each@isc.org>
Sun, 7 Jul 2013 01:23:41 +0000 (18:23 -0700)
committerEvan Hunt <each@isc.org>
Sun, 7 Jul 2013 01:23:41 +0000 (18:23 -0700)
3609. [bug] Corrected a possible deadlock in applications using
the export version of the isc_app API. [RT #33967]

CHANGES
lib/isc/unix/app.c

diff --git a/CHANGES b/CHANGES
index 9fcb86bb582a1fc327b4ee3ed909866b722af0ff..c7e421adde5dfa04d8e6176d2ed2758e5d0589c5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3609.  [bug]           Corrected a possible deadlock in applications using
+                       the export version of the isc_app API. [RT #33967]
+
 3608.  [port]          win32: added todos.pl script to ensure all text files
                        the win32 build depends on are converted to DOS
                        newline format. [RT #22067]
index 81eb29cf89edec36b85dff7d8835c212c05a90ba..2cea67ab5ffdc0d64490ce85813fa06ef2fd56e2 100644 (file)
@@ -690,6 +690,11 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
                         * wait until woken up.
                         */
                        LOCK(&ctx->readylock);
+                       if (ctx->want_shutdown) {
+                               /* shutdown() won the race. */
+                               UNLOCK(&ctx->readylock);
+                               break;
+                       }
                        if (!ctx->want_reload)
                                WAIT(&ctx->ready, &ctx->readylock);
                        UNLOCK(&ctx->readylock);
@@ -719,7 +724,13 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
                         * wait until woken up.
                         */
                        LOCK(&ctx->readylock);
-                       WAIT(&ctx->ready, &ctx->readylock);
+                       if (ctx->want_shutdown) {
+                               /* shutdown() won the race. */
+                               UNLOCK(&ctx->readylock);
+                               break;
+                       }
+                       if (!ctx->want_reload)
+                               WAIT(&ctx->ready, &ctx->readylock);
                        UNLOCK(&ctx->readylock);
                }
 #endif /* HAVE_SIGWAIT */
@@ -802,7 +813,9 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
 #endif /* HAVE_LINUXTHREADS */
                        else {
                                /* External, multiple contexts */
+                               LOCK(&ctx->readylock);
                                ctx->want_shutdown = ISC_TRUE;
+                               UNLOCK(&ctx->readylock);
                                SIGNAL(&ctx->ready);
                        }
 #endif /* ISC_PLATFORM_USETHREADS */
@@ -878,7 +891,9 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
 #endif /* HAVE_LINUXTHREADS */
                        else {
                                /* External, multiple contexts */
+                               LOCK(&ctx->readylock);
                                ctx->want_reload = ISC_TRUE;
+                               UNLOCK(&ctx->readylock);
                                SIGNAL(&ctx->ready);
                        }
 #endif /* ISC_PLATFORM_USETHREADS */