mirror of
https://github.com/apple/swift-nio
synced 2026-11-29 05:24:21 +00:00
downgrade 'schedule after shutdown' to printing error (#1454)
Motivation: Since #1395, we crash when something is scheduled to an already shutdown EventLoop. That's a good intent (#1383) but we feel it's a little too risky right now. Modifications: Print an ERROR instead of just crashing. Result: Fewer crashes.
This commit is contained in:
1 parent
2ad77f9a9b
commit
bd4df32a26
1 file changed
+6
-3
@@ -254,15 +254,18 @@ internal final class SelectableEventLoop: EventLoop {
|
||||
internal func _schedule0(_ task: ScheduledTask) throws {
|
||||
if self.inEventLoop {
|
||||
precondition(self._validInternalStateToScheduleTasks,
|
||||
"cannot schedule tasks on an EventLoop that has already shut down")
|
||||
"BUG IN NIO (please report): EventLoop is shutdown, yet we're on the EventLoop.")
|
||||
|
||||
self._tasksLock.withLockVoid {
|
||||
self._scheduledTasks.push(task)
|
||||
}
|
||||
} else {
|
||||
self.externalStateLock.withLockVoid {
|
||||
precondition(self._validExternalStateToScheduleTasks,
|
||||
"cannot schedule tasks on an EventLoop that has already shut down")
|
||||
guard self._validExternalStateToScheduleTasks else {
|
||||
print("ERROR: Cannot schedule tasks on an EventLoop that has already shut down. " +
|
||||
"This will be upgraded to a forced crash in future SwiftNIO versions.")
|
||||
return
|
||||
}
|
||||
|
||||
self._tasksLock.withLockVoid {
|
||||
self._scheduledTasks.push(task)
|
||||
|
||||
Reference in new issue
Block a user