Skip to content
Browse files

zlib: emit "close" if Z_STREAM_END occurs.

  • Loading branch information...
1 parent 0cf2354 commit 45cb346eb1dd0e1f1e9385b55befe4f2e5a5dbce @npcode committed Jul 21, 2012
Showing with 7 additions and 2 deletions.
  1. +5 −1 lib/zlib.js
  2. +2 −1 src/node_zlib.cc
View
6 lib/zlib.js
@@ -392,7 +392,7 @@ Zlib.prototype._process = function() {
req.callback = callback;
this._processing = req;
- function callback(availInAfter, availOutAfter, buffer) {
+ function callback(err, availInAfter, availOutAfter, buffer) {
if (self._hadError) return;
var have = availOutBefore - availOutAfter;
@@ -438,6 +438,10 @@ Zlib.prototype._process = function() {
self._processing = false;
if (cb) cb();
self._process();
+
+ if (err == binding.Z_STREAM_END) {
+ self.emit('close');
+ }
}
};
View
3 src/node_zlib.cc
@@ -211,7 +211,8 @@ class ZCtx : public ObjectWrap {
// call the write() cb
assert(ctx->handle_->Get(callback_sym)->IsFunction() &&
"Invalid callback");
- Local<Value> args[2] = { avail_in, avail_out };
+ Local<Value> args[3] = { Local<Value>::New(Number::New(ctx->err_)),
+ avail_in, avail_out };
MakeCallback(ctx->handle_, callback_sym, ARRAY_SIZE(args), args);
ctx->Unref();

0 comments on commit 45cb346

Please sign in to comment.
Something went wrong with that request. Please try again.