]> 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:03:41 +0000 (22:03 +0000)
committerEvan Hunt <each@isc.org>
Fri, 3 Dec 2010 22:03:41 +0000 (22:03 +0000)
"rndc stop" commands were issued at the same
time. [RT #22108]

CHANGES
bin/named/control.c
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 6b0543ea2426c9c3ca0d2a1fbcc5fb90fe38dd85..c64ca2c36ecbea766be5ca964cfc1842369733e7 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]
 
 2976.  [bug]           named could die on exit after negotiating a GSS-TSIG
index ac1ec4217dad87d15782de5a9d8edd01e6dc813c..0bfd709f1067c1827af56869c9973e0af7170aa4 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: control.c,v 1.33.266.2 2009/07/11 23:47:17 tbox Exp $ */
+/* $Id: control.c,v 1.33.266.3 2010/12/03 22:03:40 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 8106571c761e7f49bbcfe099731e4b06bbe5c7e6..6c5c17bbd5fe6d79a8c469a7f0b389dc5fbe8843 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: task.h,v 1.61.332.2 2009/01/18 23:47:41 tbox Exp $ */
+/* $Id: task.h,v 1.61.332.3 2010/12/03 22:03:41 each Exp $ */
 
 #ifndef ISC_TASK_H
 #define ISC_TASK_H 1
@@ -535,6 +535,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 a630173d940556dabd3ae01472de8d5fc66e4ae0..e519aa8a4a4f2d23352009dc7137b34c1f3147fe 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: task.c,v 1.107 2008/03/27 23:46:57 tbox Exp $ */
+/* $Id: task.c,v 1.107.120.1 2010/12/03 22:03:40 each Exp $ */
 
 /*! \file
  * \author Principal Author: Bob Halley
@@ -1292,8 +1292,15 @@ isc_task_endexclusive(isc_task_t *task) {
 #endif
 }
 
-#ifdef HAVE_LIBXML2
+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));
+}
 
+#ifdef HAVE_LIBXML2
 void
 isc_taskmgr_renderxml(isc_taskmgr_t *mgr, xmlTextWriterPtr writer)
 {
index 4ae4f101dcdd6b3e13526d17a8cf8b91d7bbf4d5..7fa9b2e977b102173a9e74cbd4ed3aeca8640d07 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: socket.c,v 1.308.12.15 2010/12/03 00:59:31 marka Exp $ */
+/* $Id: socket.c,v 1.308.12.16 2010/12/03 22:03:41 each Exp $ */
 
 /*! \file */
 
@@ -4855,6 +4855,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++;
        nsock->statsindex = sock->statsindex;
 
index a8fc76d5646ade9db0df98002e331abf3f590d84..928c1f7c6467c92614103e591c4d220d721ad082 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: socket.c,v 1.70.54.7 2010/11/18 00:58:40 tbox Exp $ */
+/* $Id: socket.c,v 1.70.54.8 2010/12/03 22:03:41 each Exp $ */
 
 /* This code uses functions which are only available on Server 2003 and
  * higher, and Windows XP and higher.
@@ -3311,6 +3311,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;