[DRBD-cvs] svn commit by phil - r2435 - trunk/drbd - Fixed the use of init_completion(), complete() and wait

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Wed Sep 20 12:52:04 CEST 2006


Author: phil
Date: 2006-09-20 12:52:03 +0200 (Wed, 20 Sep 2006)
New Revision: 2435

Modified:
   trunk/drbd/drbd_main.c
Log:
Fixed the use of init_completion(), complete() and wait_for_completion()


Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2006-09-20 10:20:51 UTC (rev 2434)
+++ trunk/drbd/drbd_main.c	2006-09-20 10:52:03 UTC (rev 2435)
@@ -1042,8 +1042,6 @@
 	spin_lock_init(&thi->t_lock);
 	thi->task    = NULL;
 	thi->t_state = None;
-	init_completion(&thi->startstop);
-
 	thi->function = func;
 	thi->mdev = mdev;
 }
@@ -1063,6 +1061,7 @@
 	     thi->t_state); */
 
 	if (thi->t_state == None) {
+		init_completion(&thi->startstop);
 		D_ASSERT(thi->task == NULL);
 		thi->t_state = Running;
 		spin_unlock(&thi->t_lock);
@@ -1113,10 +1112,10 @@
 
 		thi->t_state = ns;
 		smp_mb();
-		if (thi->task != current)
+		if (thi->task != current) {
+			if(wait) init_completion(&thi->startstop);
 			force_sig(DRBD_SIGKILL,thi->task);
-		else
-			D_ASSERT(!wait);
+		} else D_ASSERT(!wait);
 	}
 	spin_unlock(&thi->t_lock);
 



More information about the drbd-cvs mailing list