mirror of
https://github.com/apple/swift-nio
synced 2026-11-28 05:14:23 +00:00
fix potential deadlock in BlockingIOThreadPool (#634)
Motivation: BlockingIOThreadPool used to call out with a lock held and on top of that on the wrong thread... Modifications: Make BlockingIOThreadPool call out on the supplied `queue` Result: fewer deadlock and surprises
This commit is contained in:
1 parent
9bae007a15
commit
176dd6e856
3 files changed
+84
-2
No files matched your search
@@ -68,7 +68,9 @@ public final class BlockingIOThreadPool {
|
||||
self.lock.withLock {
|
||||
switch self.state {
|
||||
case .running(let items):
|
||||
items.forEach { $0(.cancelled) }
|
||||
queue.async {
|
||||
items.forEach { $0(.cancelled) }
|
||||
}
|
||||
self.state = .shuttingDown(Array(repeating: true, count: numberOfThreads))
|
||||
(0..<numberOfThreads).forEach { _ in
|
||||
self.semaphore.signal()
|
||||
@@ -162,7 +164,7 @@ public final class BlockingIOThreadPool {
|
||||
self.queues.enumerated().forEach { idAndQueue in
|
||||
let id = idAndQueue.0
|
||||
let q = idAndQueue.1
|
||||
q.async { [unowned self] in
|
||||
q.async {
|
||||
self.process(identifier: id)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user