Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys/sys Ooops - we need to grab the mutex before w...



details:   https://anonhg.NetBSD.org/src/rev/039d9f82bf3a
branches:  pgoyette-compat
changeset: 830728:039d9f82bf3a
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Sep 19 06:26:13 2018 +0000

description:
Ooops - we need to grab the mutex before we can drain the localcount!

diffstat:

 sys/sys/module_hook.h |  7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diffs (28 lines):

diff -r 0a75a4b92dfb -r 039d9f82bf3a sys/sys/module_hook.h
--- a/sys/sys/module_hook.h     Wed Sep 19 04:22:33 2018 +0000
+++ b/sys/sys/module_hook.h     Wed Sep 19 06:26:13 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: module_hook.h,v 1.1.2.1 2018/09/18 21:38:08 pgoyette Exp $ */
+/* $NetBSD: module_hook.h,v 1.1.2.2 2018/09/19 06:26:13 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -116,6 +116,9 @@
        KASSERT(hook.hooked);                                   \
        KASSERT(hook.f);                                        \
                                                                \
+       /* Grab the mutex */                                    \
+       mutex_enter(&hook.mtx);                                 \
+                                                               \
        /* Prevent new localcount_acquire calls.  */            \
        hook.hooked = false;                                    \
                                                                \
@@ -125,6 +128,8 @@
        /* Wait for existing localcount references to drain.  */\
        localcount_drain(&hook.lc, &hook.cv, &hook.mtx);        \
                                                                \
+       /* Release the mutex and clean up all resources */      \
+       mutex_exit(&hook.mtx);                                  \
        localcount_fini(&hook.lc);                              \
        cv_destroy(&hook.cv);                                   \
        mutex_destroy(&hook.mtx);                               \



Home | Main Index | Thread Index | Old Index