diff options
author | Timothy J Fontaine <tjfontaine@gmail.com> | 2014-02-17 20:57:53 -0800 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2014-02-17 20:57:53 -0800 |
commit | 466a9b5c78abef8f6c5261f33df83672d78b41b5 (patch) | |
tree | 3acb06281dbb1bf16afe77b975db5426e346094c /src/node_zlib.cc | |
parent | e5eadcfa199298d6b6f14df43cfcdd5b478c6208 (diff) | |
parent | 562b015170c4c0bf442d49d46332fb3918173306 (diff) | |
download | android-node-v8-466a9b5c78abef8f6c5261f33df83672d78b41b5.tar.gz android-node-v8-466a9b5c78abef8f6c5261f33df83672d78b41b5.tar.bz2 android-node-v8-466a9b5c78abef8f6c5261f33df83672d78b41b5.zip |
Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
src/node_zlib.cc
Diffstat (limited to 'src/node_zlib.cc')
-rw-r--r-- | src/node_zlib.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 0ad65d1d73..90c5e10c47 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -87,17 +87,24 @@ class ZCtx : public AsyncWrap { strategy_(0), windowBits_(0), write_in_progress_(false), + pending_close_(false), refs_(0) { MakeWeak<ZCtx>(this); } ~ZCtx() { + assert(!write_in_progress_ && "write in progress"); Close(); } void Close() { - assert(!write_in_progress_ && "write in progress"); + if (write_in_progress_) { + pending_close_ = true; + return; + } + + pending_close_ = false; assert(init_done_ && "close before init"); assert(mode_ <= UNZIP); @@ -136,6 +143,7 @@ class ZCtx : public AsyncWrap { assert(ctx->mode_ != NONE && "already finalized"); assert(!ctx->write_in_progress_ && "write already in progress"); + assert(!ctx->pending_close_ && "close is pending"); ctx->write_in_progress_ = true; ctx->Ref(); @@ -323,6 +331,8 @@ class ZCtx : public AsyncWrap { ctx->MakeCallback(env->callback_string(), ARRAY_SIZE(args), args); ctx->Unref(); + if (ctx->pending_close_) + ctx->Close(); } static void Error(ZCtx* ctx, const char* message) { @@ -345,6 +355,8 @@ class ZCtx : public AsyncWrap { // no hope of rescue. ctx->write_in_progress_ = false; ctx->Unref(); + if (ctx->pending_close_) + ctx->Close(); } static void New(const FunctionCallbackInfo<Value>& args) { @@ -578,6 +590,7 @@ class ZCtx : public AsyncWrap { int windowBits_; uv_work_t work_req_; bool write_in_progress_; + bool pending_close_; unsigned int refs_; }; |