Skip to content

Commit

Permalink
Merge pull request #77 from hummingbird-project/dont-use-next-isolation
Browse files Browse the repository at this point in the history
Don't use next(isolation:) as it has OS requirements
  • Loading branch information
Joannis authored Aug 26, 2024
2 parents 96f37f6 + 85e1db8 commit 1505910
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions Sources/HummingbirdWSCore/WebSocketHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ package actor WebSocketHandler {
handler: @escaping WebSocketDataHandler<Context>,
context: Context
) async throws -> WebSocketCloseFrame? {
let webSocketOutbound = WebSocketOutboundWriter(handler: self)
var inboundIterator = inbound.makeAsyncIterator()
let webSocketInbound = WebSocketInboundStream(
iterator: inboundIterator,
handler: self
)
try await withGracefulShutdownHandler {
let webSocketOutbound = WebSocketOutboundWriter(handler: self)
var inboundIterator = inbound.makeAsyncIterator()
let webSocketInbound = WebSocketInboundStream(
iterator: inboundIterator,
handler: self
)
let closeCode: WebSocketErrorCode
do {
// handle websocket data and text
Expand All @@ -179,21 +179,12 @@ package actor WebSocketHandler {
try await self.close(code: closeCode)
if case .closing = self.closeState {
// Close handshake. Wait for responding close or until inbound ends
#if compiler(>=6.0)
while let frame = try await inboundIterator.next(isolation: self) {
if case .connectionClose = frame.opcode {
try await self.receivedClose(frame)
break
}
}
#else
while let frame = try await inboundIterator.next() {
if case .connectionClose = frame.opcode {
try await self.receivedClose(frame)
break
}
}
#endif
}
// don't propagate error if channel is already closed
} catch ChannelError.ioOnClosedChannel {}
Expand Down

0 comments on commit 1505910

Please sign in to comment.