]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2979. [bug] named could deadlock during shutdown if two
authorEvan Hunt <each@isc.org>
Fri, 3 Dec 2010 22:04:49 +0000 (22:04 +0000)
committerEvan Hunt <each@isc.org>
Fri, 3 Dec 2010 22:04:49 +0000 (22:04 +0000)
"rndc stop" commands were issued at the same
time. [RT #22108]

CHANGES
bin/named/control.c
lib/isc/include/isc/namespace.h
lib/isc/include/isc/task.h
lib/isc/task.c
lib/isc/unix/socket.c
lib/isc/win32/socket.c

diff --git a/CHANGES b/CHANGES
index 0d61c7e7025279c928509f75845dd1ff83b7905f..bc9415595fba9d54f36303d1778ab0692b265036 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+2979.  [bug]           named could deadlock during shutdown if two
+                       "rndc stop" commands were issued at the same
+                       time. [RT #22108]
+
 2978.  [port]          hpux: look for <devpoll.h> [RT #21919]
 
 2977.  [bug]           'nsupdate -l' report if the session key is missing.
index ac01c4d1570e99d18a8657137780b845a22b7d4c..3e6ef6ab4650578b1f2b9a515436e739ec5efeac 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: control.c,v 1.36.50.4 2010/08/16 22:27:16 marka Exp $ */
+/* $Id: control.c,v 1.36.50.5 2010/12/03 22:04:49 each Exp $ */
 
 /*! \file */
 
@@ -129,11 +129,16 @@ ns_control_docommand(isccc_sexpr_t *message, isc_buffer_t *text) {
                 * isc_app_shutdown below.
                 */
 #endif
+               /* Do not flush master files */
                ns_server_flushonshutdown(ns_g_server, ISC_FALSE);
                ns_os_shutdownmsg(command, text);
                isc_app_shutdown();
                result = ISC_R_SUCCESS;
        } else if (command_compare(command, NS_COMMAND_STOP)) {
+               /*
+                * "stop" is the same as "halt" except it does
+                * flush master files.
+                */
 #ifdef HAVE_LIBSCF
                if (ns_smf_got_instance == 1 && ns_smf_chroot == 1) {
                        result = ns_smf_add_message(text);
index 1e9e1229f41b9c5bcef24f4b5b7aa1afc4a26562..e6d13358c422fef70746d677ea161bb41fae22a4 100644 (file)
@@ -14,7 +14,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: namespace.h,v 1.5.62.2 2010/08/13 23:46:28 tbox Exp $ */
+/* $Id: namespace.h,v 1.5.62.3 2010/12/03 22:04:49 each Exp $ */
 
 #ifndef ISCAPI_NAMESPACE_H
 #define ISCAPI_NAMESPACE_H 1
 #define isc_task_create isc__task_create
 #define isc_task_attach isc__task_attach
 #define isc_task_detach isc__task_detach
+#define isc_task_exiting isc__task_exiting
 #define isc_task_send isc__task_send
 #define isc_task_sendanddetach isc__task_sendanddetach
 #define isc_task_purgerange isc__task_purgerange
index 2fe99c475241f2732f376e4b37da4e762ef82cba..1b1d2e585048ddac3b84a6de43caa527b2038189 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: task.h,v 1.65 2009/09/02 18:38:40 jinmei Exp $ */
+/* $Id: task.h,v 1.65.104.1 2010/12/03 22:04:49 each Exp $ */
 
 #ifndef ISC_TASK_H
 #define ISC_TASK_H 1
@@ -599,6 +599,16 @@ isc_task_getcurrenttime(isc_task_t *task, isc_stdtime_t *t);
  *\li  '*t' has the "current time".
  */
 
+isc_boolean_t
+isc__task_exiting(isc_task_t *t);
+/*%<
+ * Returns ISC_TRUE if the task is in the process of shutting down,
+ * ISC_FALSE otherwise.
+ *
+ * Requires:
+ *\li  'task' is a valid task.
+ */
+
 /*****
  ***** Task Manager.
  *****/
index f70ea490fcac6b5e9eabe80fd3a754ef63c2a3f2..00f374295b0de366b9e95f6866ebc7e79fc8d411 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: task.c,v 1.111 2009/10/05 17:30:49 fdupont Exp $ */
+/* $Id: task.c,v 1.111.60.1 2010/12/03 22:04:49 each Exp $ */
 
 /*! \file
  * \author Principal Author: Bob Halley
@@ -1482,6 +1482,15 @@ isc__task_register() {
 }
 #endif
 
+isc_boolean_t
+isc__task_exiting(isc_task_t *t) {
+       isc__task_t *task = (isc__task_t *)t;
+
+       REQUIRE(VALID_TASK(task));
+       return (TASK_SHUTTINGDOWN(task));
+}
+
+
 #if defined(HAVE_LIBXML2) && defined(BIND9)
 void
 isc_taskmgr_renderxml(isc_taskmgr_t *mgr0, xmlTextWriterPtr writer) {
index ee651f5ac04c50d68c22ee7da0afe6d7cdb4e3b2..18062956345c044e100af1adba2689a9d2b87fbe 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: socket.c,v 1.326.20.5 2010/12/03 00:57:32 marka Exp $ */
+/* $Id: socket.c,v 1.326.20.6 2010/12/03 22:04:49 each Exp $ */
 
 /*! \file */
 
@@ -5115,6 +5115,12 @@ isc__socket_accept(isc_socket_t *sock0,
         * Attach to socket and to task.
         */
        isc_task_attach(task, &ntask);
+       if (isc_task_exiting(ntask)) {
+               isc_task_detach(&ntask);
+               isc_event_free(ISC_EVENT_PTR(&dev));
+               UNLOCK(&sock->lock);
+               return (ISC_R_SHUTTINGDOWN);
+       }
        nsock->references++;
        nsock->statsindex = sock->statsindex;
 
index 040371dcf9c94ac431b1c242483412fdc25e5346..54b4ab9d2356e0e70b9bfa0e22a90d3330e4d49b 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: socket.c,v 1.81.22.3 2010/11/18 00:59:15 tbox Exp $ */
+/* $Id: socket.c,v 1.81.22.4 2010/12/03 22:04:49 each Exp $ */
 
 /* This code uses functions which are only available on Server 2003 and
  * higher, and Windows XP and higher.
@@ -3313,6 +3313,12 @@ isc__socket_accept(isc_socket_t *sock,
         * Attach to socket and to task.
         */
        isc_task_attach(task, &ntask);
+       if (isc_task_exiting(ntask)) {
+               isc_task_detach(&ntask);
+               isc_event_free(ISC_EVENT_PTR(&dev));
+               UNLOCK(&sock->lock);
+               return (ISC_R_SHUTTINGDOWN);
+       }
        nsock->references++;
 
        adev->ev_sender = ntask;