Loading...
--- xnu/xnu-201.42.3/iokit/Kernel/IOLocks.cpp
+++ xnu/xnu-124.7/iokit/Kernel/IOLocks.cpp
@@ -49,6 +49,8 @@
void IOLockInitWithState( IOLock * lock, IOLockState state)
{
+ mutex_init( lock, ETAP_IO_AHA);
+
if( state == kIOLockStateLocked)
IOLockLock( lock);
}
@@ -94,7 +96,7 @@
if( lock->thread == IOThreadSelf())
lock->count++;
else {
- mutex_lock( lock->mutex );
+ _mutex_lock( lock->mutex );
assert( lock->thread == 0 );
assert( lock->count == 0 );
lock->thread = IOThreadSelf();
@@ -110,7 +112,7 @@
lock->count++;
return( true );
} else {
- if( mutex_try( lock->mutex )) {
+ if( _mutex_try( lock->mutex )) {
assert( lock->thread == 0 );
assert( lock->count == 0 );
lock->thread = IOThreadSelf();
@@ -156,13 +158,13 @@
res = thread_block(0);
- // Must re-establish the recursive lock no matter why we woke up
- // otherwise we would potentially leave the return path corrupted.
- mutex_lock(lock->mutex);
- assert(lock->thread == 0);
- assert(lock->count == 0);
- lock->thread = IOThreadSelf();
- lock->count = count;
+ if (THREAD_AWAKENED == res) {
+ _mutex_lock(lock->mutex);
+ assert(lock->thread == 0);
+ assert(lock->count == 0);
+ lock->thread = IOThreadSelf();
+ lock->count = count;
+ }
return res;
}