changeset 13317:bd2d2a5ed3e4

875 missing lwp_exit() in kcfpool_svc() induces panic in prchoose() Reviewed by: Bryan Cantrill <bryancantrill@gmail.com> Reviewed by: Dan McDonald <danmcd@nexenta.com> Approved by: Gordon Ross <gwr@nexenta.com>
author Garrett D'Amore <garrett@nexenta.com>
date Sun, 03 Apr 2011 07:44:01 -0700
parents e4e8c441a977
children baafb764c755
files usr/src/uts/common/crypto/core/kcf_sched.c
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/crypto/core/kcf_sched.c	Sat Apr 02 21:46:38 2011 -0700
+++ b/usr/src/uts/common/crypto/core/kcf_sched.c	Sun Apr 03 07:44:01 2011 -0700
@@ -23,7 +23,7 @@
  */
 
 /*
- * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
@@ -1034,7 +1034,17 @@
 				if (kcfpool->kp_threads > kcf_minthreads) {
 					KCF_ATOMIC_DECR(kcfpool->kp_threads);
 					mutex_exit(&gswq->gs_lock);
-					return;
+
+					/*
+					 * lwp_exit() assumes it is called
+					 * with the proc lock held.  But the
+					 * first thing it does is drop it.
+					 * This ensures that lwp does not
+					 * exit before lwp_create is done
+					 * with it.
+					 */
+					mutex_enter(&curproc->p_lock);
+					lwp_exit();	/* does not return */
 				}
 
 				/* Resume the wait for work. */
@@ -1405,7 +1415,7 @@
 	 */
 	for (;;) {
 		int rv;
-		
+
 		CALLB_CPR_SAFE_BEGIN(&cprinfo);
 		rv = cv_reltimedwait(&kcfpool->kp_cv,
 		    &kcfpool->kp_lock, timeout_val, TR_CLOCK_TICK);