Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern logread_filtops is MPSAFE.



details:   https://anonhg.NetBSD.org/src/rev/c99d2bde928b
branches:  trunk
changeset: 1023800:c99d2bde928b
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Sep 26 15:11:33 2021 +0000

description:
logread_filtops is MPSAFE.

diffstat:

 sys/kern/subr_log.c |  15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diffs (49 lines):

diff -r 1368da556e48 -r c99d2bde928b sys/kern/subr_log.c
--- a/sys/kern/subr_log.c       Sun Sep 26 15:10:51 2021 +0000
+++ b/sys/kern/subr_log.c       Sun Sep 26 15:11:33 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_log.c,v 1.61 2021/09/26 01:16:10 thorpej Exp $    */
+/*     $NetBSD: subr_log.c,v 1.62 2021/09/26 15:11:33 thorpej Exp $    */
 
 /*-
  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_log.c,v 1.61 2021/09/26 01:16:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_log.c,v 1.62 2021/09/26 15:11:33 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -290,7 +290,7 @@
 }
 
 static const struct filterops logread_filtops = {
-       .f_flags = FILTEROP_ISFD,
+       .f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE,
        .f_attach = NULL,
        .f_detach = filt_logrdetach,
        .f_event = filt_logread,
@@ -303,18 +303,15 @@
        switch (kn->kn_filter) {
        case EVFILT_READ:
                kn->kn_fop = &logread_filtops;
+               mutex_spin_enter(&log_lock);
+               selrecord_knote(&log_selp, kn);
+               mutex_spin_exit(&log_lock);
                break;
 
        default:
                return (EINVAL);
        }
 
-       kn->kn_hook = NULL;
-
-       mutex_spin_enter(&log_lock);
-       selrecord_knote(&log_selp, kn);
-       mutex_spin_exit(&log_lock);
-
        return (0);
 }
 



Home | Main Index | Thread Index | Old Index