[haiku-commits] Change in haiku[master]: freebsd_network: Implement mtx_destroy for spinlocks.

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 26 Mar 2020 21:25:59 +0000

From Navin Barnwal <knbarnwal@xxxxxxxxx>:

Hello waddlesplash,

I'd like you to do a code review. Please visit

    https://review.haiku-os.org/c/haiku/+/2436

to review the following change.


Change subject: freebsd_network: Implement mtx_destroy for spinlocks.
......................................................................

freebsd_network: Implement mtx_destroy for spinlocks.

Somehow, I missed this when implementing MTX_SPIN in the first place,
and it went largely unnoticed because MTX_SPIN is rarely used and
apparently even more rarely destroyed.

Should fix #15749.

Change-Id: Iccb0f436e3adc7365d0095eb771661e3eb87eaf6

Patch for bug id:- 2266
Change ID:- I7fceb92021b13df453c11325964ea3e718b82e39

Change-Id: Ia480d17a137bdb64e1397dbc9794104368c125c3
---
M src/libs/compat/freebsd_network/mutex.c
1 file changed, 5 insertions(+), 4 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/36/2436/1

diff --git a/src/libs/compat/freebsd_network/mutex.c 
b/src/libs/compat/freebsd_network/mutex.c
index 4a035fb..1084437 100644
--- a/src/libs/compat/freebsd_network/mutex.c
+++ b/src/libs/compat/freebsd_network/mutex.c
@@ -10,8 +10,6 @@
 #include <compat/sys/mutex.h>


-// these methods are bit unfriendly, a bit too much panic() around
-
 struct mtx Giant;
 struct rw_lock ifnet_rwlock;
 struct mtx gIdStoreLock;
@@ -49,10 +47,13 @@
 void
 mtx_destroy(struct mtx *mutex)
 {
-       if ((mutex->type & MTX_RECURSE) != 0)
+       if ((mutex->type & MTX_RECURSE) != 0) {
                recursive_lock_destroy(&mutex->u.recursive);
-       else
+       } else if ((mutex->type & MTX_SPIN) != 0) {
+               KASSERT(!B_SPINLOCK_IS_LOCKED(&mutex->u.spinlock.lock), ("spin 
mutex is locked"));
+       } else {
                mutex_destroy(&mutex->u.mutex.lock);
+       }
 }



--
To view, visit https://review.haiku-os.org/c/haiku/+/2436
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: Ia480d17a137bdb64e1397dbc9794104368c125c3
Gerrit-Change-Number: 2436
Gerrit-PatchSet: 1
Gerrit-Owner: Navin Barnwal <knbarnwal@xxxxxxxxx>
Gerrit-Reviewer: waddlesplash <waddlesplash@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: freebsd_network: Implement mtx_destroy for spinlocks. - Gerrit