Created
October 12, 2011 22:00
-
-
Save isaacs/1282775 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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