mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-26 04:57:50 +00:00
Ensure that we fire channelActive and channelInactive in order (#373)
Motivation: channelActive must always precede channelInactive. Unfortunately, this isn't guaranteed right now: if we happen to get channelInactive as a result of our writing the preamble we'll fire them in the wrong order. Many systems can tolerate this, but we should avoid doing this anyway. Modifications: - Added a state enum to keep track of the state we're in - Use that state enum to ensure we deliver active/inactive in the right order - Additionally police other unexpected active/inactive behaviours Result: We'll appropriately police the state.
This commit is contained in:
1 parent
5fcdf62ae8
commit
8dcda68288
6 files changed
+370
-6
No files matched your search
@@ -1622,6 +1622,25 @@ public enum NIOHTTP2Errors {
|
||||
self.storage = .init(streamID: streamID, baseError: baseError)
|
||||
}
|
||||
}
|
||||
|
||||
public struct ActivationError: NIOHTTP2Error, CustomStringConvertible {
|
||||
private let state: NIOHTTP2Handler.ActivationState
|
||||
|
||||
private var activating: Bool
|
||||
|
||||
init(state: NIOHTTP2Handler.ActivationState, activating: Bool) {
|
||||
self.state = state
|
||||
self.activating = activating
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
if self.activating {
|
||||
return "Error during activation: in state \(self.state)"
|
||||
} else {
|
||||
return "Error during inactivation: in state \(self.state)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user