Source-Changes-HG archive

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

[src/trunk]: src/external/cddl/osnet/dev Fix module unload of dtrace, sdt and...



details:   https://anonhg.NetBSD.org/src/rev/31221a8da84b
branches:  trunk
changeset: 806480:31221a8da84b
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Feb 26 09:10:52 2015 +0000

description:
Fix module unload of dtrace, sdt and fbt

- Don't unload when there are users of dtrace
- Forbid auto unloading (not supported for now)

PR 49695

diffstat:

 external/cddl/osnet/dev/dtrace/dtrace_modevent.c |   9 +++++++--
 external/cddl/osnet/dev/dtrace/dtrace_unload.c   |   6 ++----
 external/cddl/osnet/dev/fbt/fbt.c                |   9 +++++++--
 external/cddl/osnet/dev/sdt/sdt.c                |  11 ++++++++---
 4 files changed, 24 insertions(+), 11 deletions(-)

diffs (122 lines):

diff -r 131741a00f05 -r 31221a8da84b external/cddl/osnet/dev/dtrace/dtrace_modevent.c
--- a/external/cddl/osnet/dev/dtrace/dtrace_modevent.c  Thu Feb 26 04:49:16 2015 +0000
+++ b/external/cddl/osnet/dev/dtrace/dtrace_modevent.c  Thu Feb 26 09:10:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dtrace_modevent.c,v 1.3 2010/03/13 22:31:15 christos Exp $     */
+/*     $NetBSD: dtrace_modevent.c,v 1.4 2015/02/26 09:10:52 ozaki-r Exp $      */
 
 /*
  * CDDL HEADER START
@@ -29,6 +29,7 @@
 dtrace_modcmd(modcmd_t cmd, void *data)
 {
        int bmajor = -1, cmajor = -1;
+       int error;
 
        switch (cmd) {
        case MODULE_CMD_INIT:
@@ -36,8 +37,12 @@
                return devsw_attach("dtrace", NULL, &bmajor,
                    &dtrace_cdevsw, &cmajor);
        case MODULE_CMD_FINI:
-               dtrace_unload();
+               error = dtrace_unload();
+               if (error != 0)
+                       return error;
                return devsw_detach(NULL, &dtrace_cdevsw);
+       case MODULE_CMD_AUTOUNLOAD:
+               return EBUSY;
        default:
                return ENOTTY;
        }
diff -r 131741a00f05 -r 31221a8da84b external/cddl/osnet/dev/dtrace/dtrace_unload.c
--- a/external/cddl/osnet/dev/dtrace/dtrace_unload.c    Thu Feb 26 04:49:16 2015 +0000
+++ b/external/cddl/osnet/dev/dtrace/dtrace_unload.c    Thu Feb 26 09:10:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dtrace_unload.c,v 1.5 2011/07/26 12:26:33 yamt Exp $   */
+/*     $NetBSD: dtrace_unload.c,v 1.6 2015/02/26 09:10:52 ozaki-r Exp $        */
 
 /*
  * CDDL HEADER START
@@ -37,9 +37,7 @@
        mutex_enter(&dtrace_lock);
        mutex_enter(&cpu_lock);
 
-       ASSERT(dtrace_opens == 0);
-
-       if (dtrace_helpers > 0) {
+       if (dtrace_opens > 0 || dtrace_helpers > 0) {
                mutex_exit(&cpu_lock);
                mutex_exit(&dtrace_lock);
                mutex_exit(&dtrace_provider_lock);
diff -r 131741a00f05 -r 31221a8da84b external/cddl/osnet/dev/fbt/fbt.c
--- a/external/cddl/osnet/dev/fbt/fbt.c Thu Feb 26 04:49:16 2015 +0000
+++ b/external/cddl/osnet/dev/fbt/fbt.c Thu Feb 26 09:10:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fbt.c,v 1.16 2014/07/26 04:54:20 ryoon Exp $   */
+/*     $NetBSD: fbt.c,v 1.17 2015/02/26 09:10:52 ozaki-r Exp $ */
 
 /*
  * CDDL HEADER START
@@ -2107,6 +2107,7 @@
 fbt_modcmd(modcmd_t cmd, void *data)
 {
        int bmajor = -1, cmajor = -1;
+       int error;
 
        switch (cmd) {
        case MODULE_CMD_INIT:
@@ -2114,8 +2115,12 @@
                return devsw_attach("fbt", NULL, &bmajor,
                    &fbt_cdevsw, &cmajor);
        case MODULE_CMD_FINI:
-               fbt_unload();
+               error = fbt_unload();
+               if (error != 0)
+                       return error;
                return devsw_detach(NULL, &fbt_cdevsw);
+       case MODULE_CMD_AUTOUNLOAD:
+               return EBUSY;
        default:
                return ENOTTY;
        }
diff -r 131741a00f05 -r 31221a8da84b external/cddl/osnet/dev/sdt/sdt.c
--- a/external/cddl/osnet/dev/sdt/sdt.c Thu Feb 26 04:49:16 2015 +0000
+++ b/external/cddl/osnet/dev/sdt/sdt.c Thu Feb 26 09:10:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdt.c,v 1.9 2014/07/26 04:54:20 ryoon Exp $    */
+/*     $NetBSD: sdt.c,v 1.10 2015/02/26 09:10:53 ozaki-r Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -433,7 +433,7 @@
                        printf("%s: failed to unregister %s error = %d\n",
                            sdt_list[ind]->name, res);
 #endif
-                       error = res;
+                       return res;
                } else {
 #ifdef SDT_DEBUG
                        printf("sdt: unregistered %s id = %d\n",
@@ -453,6 +453,7 @@
 sdt_modcmd(modcmd_t cmd, void *data)
 {
        int bmajor = -1, cmajor = -1;
+       int error;
 
        switch (cmd) {
        case MODULE_CMD_INIT:
@@ -460,8 +461,12 @@
                return devsw_attach("sdt", NULL, &bmajor,
                    &sdt_cdevsw, &cmajor);
        case MODULE_CMD_FINI:
-               sdt_unload();
+               error = sdt_unload();
+               if (error != 0)
+                       return error;
                return devsw_detach(NULL, &sdt_cdevsw);
+       case MODULE_CMD_AUTOUNLOAD:
+               return EBUSY;
        default:
                return ENOTTY;
        }



Home | Main Index | Thread Index | Old Index