Author: kib
Date: Wed Sep 16 04:35:23 2015
New Revision: 287849
URL: https://svnweb.freebsd.org/changeset/base/287849

Log:
  MFC r287366:
  Use SLIST_FOREACH_SAFE() to fix iteration.

Modified:
  stable/10/sys/kern/kern_event.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_event.c
==============================================================================
--- stable/10/sys/kern/kern_event.c     Wed Sep 16 04:27:12 2015        
(r287848)
+++ stable/10/sys/kern/kern_event.c     Wed Sep 16 04:35:23 2015        
(r287849)
@@ -1849,7 +1849,7 @@ void
 knote(struct knlist *list, long hint, int lockflags)
 {
        struct kqueue *kq;
-       struct knote *kn;
+       struct knote *kn, *tkn;
        int error;
 
        if (list == NULL)
@@ -1861,14 +1861,13 @@ knote(struct knlist *list, long hint, in
                list->kl_lock(list->kl_lockarg); 
 
        /*
-        * If we unlock the list lock (and set KN_INFLUX), we can eliminate
-        * the kqueue scheduling, but this will introduce four
-        * lock/unlock's for each knote to test.  If we do, continue to use
-        * SLIST_FOREACH, SLIST_FOREACH_SAFE is not safe in our case, it is
-        * only safe if you want to remove the current item, which we are
-        * not doing.
+        * If we unlock the list lock (and set KN_INFLUX), we can
+        * eliminate the kqueue scheduling, but this will introduce
+        * four lock/unlock's for each knote to test.  Also, marker
+        * would be needed to keep iteration position, since filters
+        * or other threads could remove events.
         */
-       SLIST_FOREACH(kn, &list->kl_list, kn_selnext) {
+       SLIST_FOREACH_SAFE(kn, &list->kl_list, kn_selnext, tkn) {
                kq = kn->kn_kq;
                KQ_LOCK(kq);
                if ((kn->kn_status & (KN_INFLUX | KN_SCAN)) == KN_INFLUX) {
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "[email protected]"

Reply via email to