Conversation
22a75e9 to
fd717f7
Compare
|
|
||
| do { | ||
| try myChannel.pipeline.syncOperations.addHandler(myGlue, position: .after(contextForInitialData.handler)) | ||
| _ = try partnerChannel.pipeline.syncOperations.handler(type: CloseOnErrorHandler.self) |
There was a problem hiding this comment.
Why are we getting the handler and throwing it away?
There was a problem hiding this comment.
The previous code seemed to do effectively that
{
partnerChannel.pipeline.handler(type: CloseOnErrorHandler.self)
}.flatMap { errorHandler in
partnerChannel.pipeline.addHandler(partnerGlue)
}
Maybe it was doing for some side-effect or maybe it was leftover code? I guess either way now it's synchronous I guess I can just delete line 98 now.
There was a problem hiding this comment.
I suspect the glue handler was meant to be added before the error handler. Normally the close-on-error handler would be the last in the pipeline.
There was a problem hiding this comment.
It looks like it is currently inserted after ChannelHandlerContext.handler where the context passed along after the error handler has been inserted, I can't work out from a glance at the code what that actually represents.
In my current changes I have just removed that line on 98. Should I change
try myChannel.pipeline.syncOperations.addHandler(myGlue, position: .after(contextForInitialData.handler))to
let closeErrorHandler = try partnerChannel.pipeline.syncOperations.handler(type: CloseOnErrorHandler.self)
try myChannel.pipeline.syncOperations.addHandler(myGlue, position: .before(closeErrorHandler))| peerChannel.close(mode: .all, promise: nil) | ||
| context.close(promise: nil) | ||
| } | ||
| context.pipeline.syncOperations.removeHandler(self, promise: nil) |
There was a problem hiding this comment.
This was only done on the success path before
| context.pipeline.removeHandler(context: $0, promise: nil) | ||
| } | ||
|
|
||
| let byteToMessageHandlerContext = try! context.pipeline.syncOperations.context(handlerType: ByteToMessageHandler<HTTPRequestDecoder>.self) |
There was a problem hiding this comment.
The previous code didn't blow up if the context couldn't be found
There was a problem hiding this comment.
I've made this no longer blow up but only remove the handler if it can be found.
| context.pipeline.context(handlerType: HTTPResponseEncoder.self).whenSuccess { | ||
| context.pipeline.removeHandler(context: $0, promise: nil) | ||
| } | ||
| let httpResponseEncoderContext = try! context.pipeline.syncOperations.context(handlerType: HTTPResponseEncoder.self) |
There was a problem hiding this comment.
I've made this no longer blow up but only remove the handler if it can be found.
| return context.channel.writeAndFlush(self.wrapOutboundOut(HTTPServerResponsePart.end(nil))) | ||
| }.whenComplete { _ in | ||
| context.channel.write(HTTPServerResponsePart.body(.byteBuffer(buffer)), promise: nil) | ||
| _ = context.channel.writeAndFlush(HTTPServerResponsePart.end(nil)) |
There was a problem hiding this comment.
The close was chain off of the write-and-flush before, now it isn't. It should either be chained off of it or we should pass promise: nil to writeAndFlush
| import Foundation | ||
|
|
||
| public enum ResultType<Value, Error> { | ||
| public enum ResultType<Value, Error>: Sendable where Value: Sendable, Error: Sendable { |
| var serverConfig: ServerConfiguration? = nil | ||
| guard let serverConfig = serverConfig else { | ||
| fatalError("You need to configure an SMTP server in code.") | ||
| } |
There was a problem hiding this comment.
The intention was for it to fatal error in this case. I've changed this to be a precondition failure instead which is hopefully more obvious
| run: echo "build-test-matrix=$(curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT" | ||
| env: | ||
| MATRIX_LINUX_COMMAND: STRICT_CONCURRENCY=true SWIFT_PACKAGE_DIRECTORIES='TLSify UniversalBootstrapDemo http-responsiveness-server connect-proxy http2-client http2-server json-rpc nio-launchd' dev/build_all.sh && SWIFT_PACKAGE_DIRECTORIES='backpressure-file-io-channel' dev/build_all.sh | ||
| MATRIX_LINUX_COMMAND: STRICT_CONCURRENCY=true SWIFT_PACKAGE_DIRECTORIES='TLSify UniversalBootstrapDemo http-responsiveness-server connect-proxy http2-client http2-server json-rpc' dev/build_all.sh && SWIFT_PACKAGE_DIRECTORIES='backpressure-file-io-channel' dev/build_all.sh |
There was a problem hiding this comment.
Rather than removing it, it probably makes more sense to update the example so that when compiling on linux it's a no-op or prints a message saying it's a Darwin only or similar.
| context.close(promise: nil) | ||
| } | ||
| } | ||
| #endif |
There was a problem hiding this comment.
Do you need an else which prints an warning that this is Darwin only?
There was a problem hiding this comment.
I do that in main.swift - is that sufficient? 4b0befb#diff-913ea37bd603731036678b1acc7dbe1d1e08da07adf3b1521c5514c9019ccf01R30
…IODemo/main.swift Co-authored-by: George Barnett <gbarnett@apple.com>
Motivation
Make the examples strict concurrency safe and lock-in those changes with CI.
Modifications
NIOSMTPwhen built in debug mode (!)nio-launchdfrom Linux CI since it requires a Darwin platformResult