changeset 6748:6c7adefd809e

6705022 *svc.startd* coredumps in restarter_insert_inst() 6706024 RC_NODE_ON_FORMER flag cleared from wrong node in rc_node_delete_children()
author rm88369
date Thu, 29 May 2008 00:08:40 -0700
parents 393cf276a040
children 22c537726e3e
files usr/src/cmd/svc/configd/rc_node.c usr/src/cmd/svc/startd/method.c
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/svc/configd/rc_node.c	Wed May 28 20:01:08 2008 -0700
+++ b/usr/src/cmd/svc/configd/rc_node.c	Thu May 29 00:08:40 2008 -0700
@@ -4335,7 +4335,7 @@
 	}
 
 	/*
-	 * when we drop cp's lock, all the children will be gone, so we
+	 * When we drop cp's lock, all the children will be gone, so we
 	 * can release DYING_FLAGS.
 	 */
 	rc_node_rele_flag(np, RC_NODE_DYING_FLAGS);
@@ -4343,7 +4343,7 @@
 		np->rn_former = NULL;		/* unlink */
 		(void) pthread_mutex_lock(&cp->rn_lock);
 		(void) pthread_mutex_unlock(&np->rn_lock);
-		np->rn_flags &= ~RC_NODE_ON_FORMER;
+		cp->rn_flags &= ~RC_NODE_ON_FORMER;
 
 		rc_node_hold_locked(cp);	/* hold while we loop */
 
--- a/usr/src/cmd/svc/startd/method.c	Wed May 28 20:01:08 2008 -0700
+++ b/usr/src/cmd/svc/startd/method.c	Thu May 29 00:08:40 2008 -0700
@@ -1151,8 +1151,13 @@
 
 out:
 	inst->ri_method_thread = 0;
+
+	/*
+	 * Unlock the mutex after broadcasting to avoid a race condition
+	 * with restarter_delete_inst() when the 'inst' structure is freed.
+	 */
+	(void) pthread_cond_broadcast(&inst->ri_method_cv);
 	MUTEX_UNLOCK(&inst->ri_lock);
-	(void) pthread_cond_broadcast(&inst->ri_method_cv);
 
 	scf_instance_destroy(s_inst);
 	scf_handle_destroy(local_handle);