Skip to content

Commit eebfb24

Browse files
authored
Pre-emptively fix sendability issues with the next NIO release (#26)
Motivation: The next NIO release includes stricter sendability checks which result in compilation errors in Swift 6 language mode. Modifications: - Change where a handler is constructed Result: Compiles with the SwiftNIO on main
1 parent 237bcc4 commit eebfb24

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Sources/GRPCNIOTransportHTTP2Posix/HTTP2ServerTransport+Posix.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ extension HTTP2ServerTransport {
8080
let serverChannel = try await ServerBootstrap(group: eventLoopGroup)
8181
.serverChannelOption(.socketOption(.so_reuseaddr), value: 1)
8282
.serverChannelInitializer { channel in
83-
let quiescingHandler = serverQuiescingHelper.makeServerChannelHandler(channel: channel)
84-
return channel.pipeline.addHandler(quiescingHandler)
83+
return channel.eventLoop.makeCompletedFuture {
84+
let quiescingHandler = serverQuiescingHelper.makeServerChannelHandler(
85+
channel: channel
86+
)
87+
return try channel.pipeline.syncOperations.addHandler(quiescingHandler)
88+
}
8589
}
8690
.bind(to: address) { channel in
8791
channel.eventLoop.makeCompletedFuture {

Sources/GRPCNIOTransportHTTP2TransportServices/HTTP2ServerTransport+TransportServices.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ extension HTTP2ServerTransport {
5858
try await bootstrap
5959
.serverChannelOption(.socketOption(.so_reuseaddr), value: 1)
6060
.serverChannelInitializer { channel in
61-
let quiescingHandler = serverQuiescingHelper.makeServerChannelHandler(channel: channel)
62-
return channel.pipeline.addHandler(quiescingHandler)
61+
return channel.eventLoop.makeCompletedFuture {
62+
let quiescingHandler = serverQuiescingHelper.makeServerChannelHandler(
63+
channel: channel
64+
)
65+
return try channel.pipeline.syncOperations.addHandler(quiescingHandler)
66+
}
6367
}
6468
.bind(to: address) { channel in
6569
channel.eventLoop.makeCompletedFuture {

0 commit comments

Comments
 (0)