Skip to content

Commit 6652060

Browse files
authored
ConditionLock deallocs its pthread_cond_t in more cases (#2901)
### Motivation: Recently we changed the init and deinit behavior of `ConditionLock`, at that time the `UnsafeMutablePointer` allocation of the held `pthread_cond_t` was put behind a conditional compiler and runtime check. The deallocation of the same object was also put behind a conditional, however the conditions were mismatched leading to a leak on some platforms. Notably this surfaced when `wait`ing on an event loop future. ### Modifications: `ConditionLock.deinit` now deallocs the held `pthread_cond_t` under the same conditions in which it allocs it. ### Result: Creating a `ConditionLock` no longer leaks memory.
1 parent fb87d5e commit 6652060

1 file changed

Lines changed: 0 additions & 2 deletions

File tree

Sources/NIOConcurrencyHelpers/lock.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ public final class ConditionLock<T: Equatable> {
159159
#elseif (compiler(<6.1) && !os(WASI)) || (compiler(>=6.1) && _runtime(_multithreaded))
160160
let err = pthread_cond_destroy(self.cond)
161161
precondition(err == 0, "\(#function) failed in pthread_cond with error \(err)")
162-
#endif
163-
#if compiler(>=6.1) && _runtime(_multithreaded)
164162
self.cond.deallocate()
165163
#endif
166164
}

0 commit comments

Comments
 (0)