mirror of
https://github.com/apple/swift-nio
synced 2026-11-26 04:57:49 +00:00
Initialize the mutexattr before use. (#3482)
As observed by @kkebo, this was missing from the implementation. ### Motivation: Correct pthread API usage. ### Modifications: Initialize the pthread_mutexattr_t with pthread_mutexattr_init before passed to pthread_mutex_init. ### Result: Even though this lock API appears to be deprecated, we'll correct the usage anyway. The non-deprecated NIOLock class doesn't have this problem.
This commit is contained in:
1 parent
6ce9173261
commit
233f61bc2c
1 file changed
+3
-1
@@ -57,7 +57,9 @@ public final class Lock {
|
||||
InitializeSRWLock(self.mutex)
|
||||
#elseif os(OpenBSD)
|
||||
var attr = pthread_mutexattr_t(bitPattern: 0)
|
||||
let err = pthread_mutex_init(self.mutex, &attr)
|
||||
var err = pthread_mutexattr_init(&attr)
|
||||
precondition(err == 0, "\(#function) failed in pthread_mutexattr_init with error \(err)")
|
||||
err = pthread_mutex_init(self.mutex, &attr)
|
||||
precondition(err == 0, "\(#function) failed in pthread_mutex with error \(err)")
|
||||
#elseif (compiler(<6.1) && !os(WASI)) || (compiler(>=6.1) && _runtime(_multithreaded))
|
||||
var attr = pthread_mutexattr_t()
|
||||
|
||||
Reference in new issue
Block a user