Skip to content

Commit 51c1358

Browse files
authored
Merge pull request #85726 from dcantah/add-errno-to-linux-lock-failures
Synchronization: Add errno to some linux lock fatalErrors
2 parents dcebf64 + 36b6b96 commit 51c1358

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

stdlib/public/Synchronization/Mutex/LinuxImpl.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ extension _MutexHandle {
137137
// Block until an equivalent '_futexUnlock' has been called by the owner.
138138
// This returns '0' on success which means the kernel has acquired the
139139
// lock for us.
140-
switch storage._futexLock() {
140+
let lockResult = storage._futexLock()
141+
switch lockResult {
141142
case 0:
142143
// Locked!
143144
return
@@ -191,7 +192,7 @@ extension _MutexHandle {
191192
// ESRCH - "The thread ID in the futex word at uaddr does not exist."
192193
default:
193194
// TODO: Replace with a colder function / one that takes a StaticString
194-
fatalError("Unknown error occurred while attempting to acquire a Mutex")
195+
fatalError("Unknown error occurred while attempting to acquire a Mutex: \(lockResult)")
195196
}
196197
}
197198
}
@@ -308,7 +309,8 @@ extension _MutexHandle {
308309
@usableFromInline
309310
internal borrowing func _unlockSlow() {
310311
while true {
311-
switch storage._futexUnlock() {
312+
let unlockResult = storage._futexUnlock()
313+
switch unlockResult {
312314
case 0:
313315
// Unlocked!
314316
return
@@ -360,7 +362,7 @@ extension _MutexHandle {
360362
// space.)"
361363
default:
362364
// TODO: Replace with a colder function / one that takes a StaticString
363-
fatalError("Unknown error occurred while attempting to release a Mutex")
365+
fatalError("Unknown error occurred while attempting to release a Mutex: \(unlockResult)")
364366
}
365367
}
366368
}

0 commit comments

Comments
 (0)