svn commit: r201304 - stable/8/sys/kern

Andrew Thompson thompsa at FreeBSD.org
Thu Dec 31 00:09:47 UTC 2009


Author: thompsa
Date: Thu Dec 31 00:09:47 2009
New Revision: 201304
URL: http://svn.freebsd.org/changeset/base/201304

Log:
  MFC r200652
  
   If the runcount is non-zero in eventhandler_deregister() then one or more
   threads are executing the eventhandler, sleep in this case to make it safe for
   module unload. If the runcount was up then an entry would have been marked
   EHE_DEAD_PRIORITY so use this as a trigger to do the wakeup in
   eventhandler_prune_list().

Modified:
  stable/8/sys/kern/subr_eventhandler.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/kern/subr_eventhandler.c
==============================================================================
--- stable/8/sys/kern/subr_eventhandler.c	Thu Dec 31 00:08:59 2009	(r201303)
+++ stable/8/sys/kern/subr_eventhandler.c	Thu Dec 31 00:09:47 2009	(r201304)
@@ -178,6 +178,8 @@ eventhandler_deregister(struct eventhand
 		ep->ee_priority = EHE_DEAD_PRIORITY;
 	}
     }
+    while (list->el_runcount > 0)
+	    mtx_sleep(list, &list->el_lock, 0, "evhrm", 0);
     EHL_UNLOCK(list);
 }
 
@@ -225,16 +227,17 @@ void
 eventhandler_prune_list(struct eventhandler_list *list)
 {
     struct eventhandler_entry *ep, *en;
+    int pruned = 0;
 
     CTR2(KTR_EVH, "%s: pruning list \"%s\"", __func__, list->el_name);
     EHL_LOCK_ASSERT(list, MA_OWNED);
-    ep = TAILQ_FIRST(&list->el_entries);
-    while (ep != NULL) {
-	en = TAILQ_NEXT(ep, ee_link);
+    TAILQ_FOREACH_SAFE(ep, &list->el_entries, ee_link, en) {
 	if (ep->ee_priority == EHE_DEAD_PRIORITY) {
 	    TAILQ_REMOVE(&list->el_entries, ep, ee_link);
 	    free(ep, M_EVENTHANDLER);
+	    pruned++;
 	}
-	ep = en;
     }
+    if (pruned > 0)
+	    wakeup(list);
 }


More information about the svn-src-all mailing list