From ea78014e005f8baadbf9b38e9e55ef99ec903271 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Thu, 22 Jun 2017 14:50:55 +0200 Subject: [PATCH] Add assert to check that used Promise was not completed yet --- Sources/NIO/ChannelPipeline.swift | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Sources/NIO/ChannelPipeline.swift b/Sources/NIO/ChannelPipeline.swift index b038c0cd9..c688007c9 100644 --- a/Sources/NIO/ChannelPipeline.swift +++ b/Sources/NIO/ChannelPipeline.swift @@ -749,25 +749,29 @@ public final class ChannelHandlerContext : ChannelInboundInvoker, ChannelOutboun func invokeRegister(promise: Promise) { assert(inEventLoop) + assert(!promise.futureResult.fulfilled, "Promise \(promise) already fulfilled") (handler as! ChannelOutboundHandler).register(ctx: self, promise: promise) } func invokeBind(local: SocketAddress, promise: Promise) { assert(inEventLoop) - + assert(!promise.futureResult.fulfilled, "Promise \(promise) already fulfilled") + (handler as! ChannelOutboundHandler).bind(ctx: self, local: local, promise: promise) } func invokeConnect(remote: SocketAddress, promise: Promise) { assert(inEventLoop) - + assert(!promise.futureResult.fulfilled, "Promise \(promise) already fulfilled") + (handler as! ChannelOutboundHandler).connect(ctx: self, remote: remote, promise: promise) } func invokeWrite(data: IOData, promise: Promise) { assert(inEventLoop) - + assert(!promise.futureResult.fulfilled, "Promise \(promise) already fulfilled") + (handler as! ChannelOutboundHandler).write(ctx: self, data: data, promise: promise) } @@ -779,7 +783,8 @@ public final class ChannelHandlerContext : ChannelInboundInvoker, ChannelOutboun func invokeWriteAndFlush(data: IOData, promise: Promise) { assert(inEventLoop) - + assert(!promise.futureResult.fulfilled, "Promise \(promise) already fulfilled") + (handler as! ChannelOutboundHandler).write(ctx: self, data: data, promise: promise) (handler as! ChannelOutboundHandler).flush(ctx: self) } @@ -792,7 +797,8 @@ public final class ChannelHandlerContext : ChannelInboundInvoker, ChannelOutboun func invokeClose(promise: Promise) { assert(inEventLoop) - + assert(!promise.futureResult.fulfilled, "Promise \(promise) already fulfilled") + (handler as! ChannelOutboundHandler).close(ctx: self, promise: promise) }