diff --git a/folly/wangle/channel/OutputBufferingHandler.h b/folly/wangle/channel/OutputBufferingHandler.h index f9a4306..a1165ca 100644 --- a/folly/wangle/channel/OutputBufferingHandler.h +++ b/folly/wangle/channel/OutputBufferingHandler.h @@ -63,6 +63,22 @@ class OutputBufferingHandler : public BytesToBytesHandler, }); } + Future close(Context* ctx) override { + if (isLoopCallbackScheduled()) { + cancelLoopCallback(); + } + + // If there are sends queued, cancel them + for (auto& promise : promises_) { + promise.setException( + folly::make_exception_wrapper( + "close() called while sends still pending")); + } + sends_.reset(); + promises_.clear(); + return ctx->fireClose(); + } + std::vector> promises_; std::unique_ptr sends_{nullptr}; bool queueSends_{true};