Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/NIOSSL/CustomPrivateKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ extension SSLConnection {
inputBytes.writeBytes(`in`)

let result = customKey.sign(channel: channel, algorithm: wrappedAlgorithm, data: inputBytes)
result.whenComplete { signingResult in
result.hop(to: channel.eventLoop).assumeIsolated().whenComplete { signingResult in
self.storeCustomPrivateKeyResult(signingResult, channel: channel)
}

Expand All @@ -178,7 +178,7 @@ extension SSLConnection {
inputBytes.writeBytes(`in`)

let result = customKey.decrypt(channel: channel, data: inputBytes)
result.whenComplete { decryptionResult in
result.hop(to: channel.eventLoop).assumeIsolated().whenComplete { decryptionResult in
self.storeCustomPrivateKeyResult(decryptionResult, channel: channel)
}

Expand Down Expand Up @@ -207,7 +207,7 @@ extension SSLConnection {
// When we complete here we need to set our result state, and then ask to respin the handshake.
// If we can't respin the handshake because we've dropped the parent handler, that's fine, no harm no foul.
// For that reason, we tolerate both the verify manager and the parent handler being nil.
channel.eventLoop.execute {
channel.eventLoop.assumeIsolated().execute {
precondition(self.customPrivateKeyResult == nil)
self.customPrivateKeyResult = result
self.parentHandler?.resumeHandshake()
Expand Down
8 changes: 4 additions & 4 deletions Sources/NIOSSL/SSLCallbacks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ extension CustomContextManager {
let promise = eventLoop.makePromise(of: NIOSSLContextConfigurationOverride.self)
self.callback(values, promise)

promise.futureResult.whenComplete { result in
promise.futureResult.assumeIsolated().whenComplete { result in
// Ensure we execute any completion on the next event loop tick
// This ensures that we suspend before calling resume
eventLoop.execute {
eventLoop.assumeIsolated().execute {
connection.parentContext.customContextManager?.state = .complete(result)
connection.parentHandler?.resumeHandshake()
}
Expand Down Expand Up @@ -445,11 +445,11 @@ extension CustomVerifyManager {

// We need to attach our "do the thing" callback. This will always invoke the "ask me again" API, and it will do so in a separate
// event loop tick to avoid awkward re-entrancy with this method.
promise.futureResult.whenComplete { result in
promise.futureResult.assumeIsolated().whenComplete { result in
// When we complete here we need to set our result state, and then ask to respin certificate verification.
// If we can't respin verification because we've dropped the parent handler, that's fine, no harm no foul.
// For that reason, we tolerate both the verify manager and the parent handler being nil.
eventLoop.execute {
eventLoop.assumeIsolated().execute {
// Note that we don't close over self here: that's to deal with the fact that this is a struct, and we don't want to
// escape the mutable ownership of self.
precondition(
Expand Down