Skip to content
Permalink
Browse files

assert EventLoopGroup::syncShutdownGracefully is not called on the ev…

…ent loop (#1151)

motivation: calling syncShutdownGracefully on the event loop can lead to deadlock

changes: assert before calling syncShutdownGracefully that no eventloop context exists
  • Loading branch information...
tomerd committed Oct 1, 2019
1 parent f548a29 commit b9293596bcef251a1fce84534554379cb8086983
Showing with 8 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +7 −0 Sources/NIO/EventLoop.swift
@@ -8,3 +8,4 @@ Package.pins
Package.resolved
.podspecs
DerivedData
.swiftpm
@@ -986,6 +986,13 @@ extension EventLoopGroup {
}

public func syncShutdownGracefully() throws {
if let eventLoop = MultiThreadedEventLoopGroup.currentEventLoop {
preconditionFailure("""
BUG DETECTED: syncShutdownGracefully() must not be called when on an EventLoop.
Calling syncShutdownGracefully() on any EventLoop can lead to deadlocks.
Current eventLoop: \(eventLoop)
""")
}
let errorStorageLock = Lock()
var errorStorage: Error? = nil
let continuation = DispatchWorkItem {}

0 comments on commit b929359

Please sign in to comment.
You can’t perform that action at this time.