From: Dave Watson Date: Wed, 8 Apr 2015 20:54:59 +0000 (-0700) Subject: Pipeline OutputBufferingHandler X-Git-Tag: v0.35.0~4 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8e2ec4c39710bf7012ddc69ae3cc55ed45ccd90c;p=folly.git Pipeline OutputBufferingHandler Summary: Part 2 of pipeline. Use OutputBufferingHandler, which is exactly the same output buffering thrift does currently. Test Plan: A couple canaries, unittests. Specific issues of previous pipeline diffs I think are fixed already and should be fine with this one: * Previously there were missing DestructorGuards. I don't think anything in OutputBUfferHandler needs a DG * previously broke http GET handling. There is a unittest for it now. Canary Reviewed By: alandau@fb.com Subscribers: doug, fugalh, alandau, bmatheny, mshneer, folly-diffs@, jsedgwick, yfeldblum, chalfant, vloh, andreib FB internal diff: D1970949 Signature: t1:1970949:1428360621:a0db142032894525f69c2b144cf946d63f790fe1 --- diff --git a/folly/wangle/channel/OutputBufferingHandler.h b/folly/wangle/channel/OutputBufferingHandler.h index f9a4306e..a1165ca1 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};