Module Name:    src
Committed By:   riastradh
Date:           Wed Apr  8 02:44:07 UTC 2015

Modified Files:
        src/sys/kern: kern_rndq.c

Log Message:
Let's use the same lock for insertion and deletion, shall we?


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/kern/kern_rndq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.32 src/sys/kern/kern_rndq.c:1.33
--- src/sys/kern/kern_rndq.c:1.32	Wed Apr  8 02:35:33 2015
+++ src/sys/kern/kern_rndq.c	Wed Apr  8 02:44:07 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.32 2015/04/08 02:35:33 riastradh Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.33 2015/04/08 02:44:07 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.32 2015/04/08 02:35:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.33 2015/04/08 02:44:07 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -730,14 +730,15 @@ rnd_detach_source(krndsource_t *source)
 {
 	rnd_sample_t *sample;
 
-	mutex_spin_enter(&rnd_mtx);
-
+	mutex_spin_enter(&rndpool_mtx);
 	LIST_REMOVE(source, list);
+	mutex_spin_exit(&rndpool_mtx);
 
 	/*
 	 * If there are samples queued up "remove" them from the sample queue
 	 * by setting the source to the no-collect pseudosource.
 	 */
+	mutex_spin_enter(&rnd_mtx);
 	sample = SIMPLEQ_FIRST(&rnd_samples);
 	while (sample != NULL) {
 		if (sample->source == source)
@@ -745,7 +746,6 @@ rnd_detach_source(krndsource_t *source)
 
 		sample = SIMPLEQ_NEXT(sample, next);
 	}
-
 	mutex_spin_exit(&rnd_mtx);
 
 	if (!cpu_softintr_p()) {	/* XXX XXX very temporary "fix" */

Reply via email to