diff options
author | Joe George <joe@zeroc.com> | 2019-07-18 15:48:20 -0400 |
---|---|---|
committer | Joe George <joe@zeroc.com> | 2019-07-18 15:48:20 -0400 |
commit | f052adbb72417989a27ae86769fdf79bcc93bbd4 (patch) | |
tree | 4a19b355d18c22aaefe62d1179660c4adcb9c675 | |
parent | Set PromiseKit version requirement (diff) | |
download | ice-f052adbb72417989a27ae86769fdf79bcc93bbd4.tar.bz2 ice-f052adbb72417989a27ae86769fdf79bcc93bbd4.tar.xz ice-f052adbb72417989a27ae86769fdf79bcc93bbd4.zip |
Additional fix for #421
We were not continuing our promising on the thread which fufilled them
-rw-r--r-- | swift/src/Ice/AdminFacetFactory.swift | 6 | ||||
-rw-r--r-- | swift/src/Ice/Incoming.swift | 13 |
2 files changed, 12 insertions, 7 deletions
diff --git a/swift/src/Ice/AdminFacetFactory.swift b/swift/src/Ice/AdminFacetFactory.swift index beb5716a8a2..fb0ba4dc78f 100644 --- a/swift/src/Ice/AdminFacetFactory.swift +++ b/swift/src/Ice/AdminFacetFactory.swift @@ -54,11 +54,13 @@ class AdminFacetFacade: ICEBlobjectFacade { func dispatch(incoming: Incoming, current: Current) { // Dispatch directly to the servant. Do not call invoke on Incoming do { + // Request was dispatched asynchronously if promise is non-nil if let promise = try disp.dispatch(request: incoming, current: current) { - promise.done { ostr in + // Use the thread which fulfilled the promise (on: nil) + promise.done(on: nil) { ostr in incoming.setResult(ostr) incoming.response() - }.catch { error in + }.catch(on: nil) { error in incoming.exception(error) } } else { diff --git a/swift/src/Ice/Incoming.swift b/swift/src/Ice/Incoming.swift index 094018c14f6..632b3ace78e 100644 --- a/swift/src/Ice/Incoming.swift +++ b/swift/src/Ice/Incoming.swift @@ -114,7 +114,8 @@ public final class Incoming { } public func setResultPromise(_ p: Promise<Void>) -> Promise<OutputStream> { - return p.map { + // Use the thread which fulfilled the promise (on: nil) + return p.map(on: nil) { let ostr = OutputStream(communicator: self.istr.communicator, encoding: self.current.encoding) ostr.writeEmptyEncapsulation(self.current.encoding) return ostr @@ -123,7 +124,8 @@ public final class Incoming { public func setResultPromise<T>(_ p: Promise<T>, _ cb: @escaping (OutputStream, T) -> Void) -> Promise<OutputStream> { - return p.map { t in + // Use the thread which fulfilled the promise (on: nil) + return p.map(on: nil) { t in let ostr = OutputStream(communicator: self.istr.communicator, encoding: self.current.encoding) ostr.startEncapsulation(encoding: self.current.encoding, format: self.format) cb(ostr, t) @@ -185,12 +187,13 @@ public final class Incoming { // Dispatch in the incoming call // do { + // Request was dispatched asynchronously if promise is non-nil if let promise = try s.dispatch(request: self, current: current) { - // dispatched asynchronously - promise.done { ostr in + // Use the thread which fulfilled the promise (on: nil) + promise.done(on: nil) { ostr in self.ostr = ostr self.response() - }.catch { error in + }.catch(on: nil) { error in self.exception(error) } } else { |