Skip to content

Instantly share code, notes, and snippets.

@isaacs isaacs/gist:1282775
Created Oct 12, 2011

Embed
What would you like to do?
diff --git a/lib/zlib.js b/lib/zlib.js
index 43725bf..a5821e7 100644
--- a/lib/zlib.js
+++ b/lib/zlib.js
@@ -246,6 +246,8 @@ Zlib.prototype.end = function end(chunk, cb) {
return ret;
};
+var reqCache = {};
+
Zlib.prototype._process = function() {
if (this._processing || this._paused) return;
@@ -270,6 +272,7 @@ Zlib.prototype._process = function() {
var availOutBefore = this._chunkSize - this._offset;
var inOff = 0;
+
var req = this._binding.write(this._flush,
chunk, // in
inOff, // in_off
@@ -282,7 +285,12 @@ Zlib.prototype._process = function() {
req.callback = callback;
this._processing = req;
+ var reqId = req.id = Math.random();
+ reqCache[reqId] = req;
+
function callback(availInAfter, availOutAfter, buffer) {
+ reqCache[reqId] = null;
+
var have = availOutBefore - availOutAfter;
assert(have >= 0, 'have should not go down');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.