mirror of https://github.com/lukechilds/node.git
Browse Source
Process at most 10 pending responses from the thread pool in one go. 10 was chosen arbitrarily. Test and report by Felix Geisendörfer <felix@debuggable.com>v0.7.4-release
Ryan Dahl
15 years ago
2 changed files with 66 additions and 0 deletions
@ -0,0 +1,63 @@ |
|||||
|
process.mixin(require("./common")); |
||||
|
|
||||
|
var |
||||
|
count = 100, |
||||
|
posix = require('posix'); |
||||
|
|
||||
|
function tryToKillEventLoop() { |
||||
|
puts('trying to kill event loop ...'); |
||||
|
|
||||
|
posix.stat(__filename) |
||||
|
.addCallback(function() { |
||||
|
puts('first posix.stat succeeded ...'); |
||||
|
|
||||
|
posix.stat(__filename) |
||||
|
.addCallback(function() { |
||||
|
puts('second posix.stat succeeded ...'); |
||||
|
puts('could not kill event loop, retrying...'); |
||||
|
|
||||
|
setTimeout(function () { |
||||
|
if (--count) { |
||||
|
tryToKillEventLoop(); |
||||
|
} else { |
||||
|
process.exit(0); |
||||
|
} |
||||
|
}, 1); |
||||
|
}) |
||||
|
.addErrback(function() { |
||||
|
throw new Exception('second posix.stat failed') |
||||
|
}) |
||||
|
|
||||
|
}) |
||||
|
.addErrback(function() { |
||||
|
throw new Exception('first posix.stat failed') |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
// Generate a lot of thread pool events
|
||||
|
var pos = 0; |
||||
|
posix.open('/dev/zero', process.O_RDONLY, 0666).addCallback(function (rd) { |
||||
|
function readChunk () { |
||||
|
posix.read(rd, 1024, pos, 'binary').addCallback(function (chunk, bytesRead) { |
||||
|
if (chunk) { |
||||
|
pos += bytesRead; |
||||
|
//puts(pos);
|
||||
|
readChunk(); |
||||
|
} else { |
||||
|
posix.close(rd); |
||||
|
throw new Exception(BIG_FILE+' should not end before the issue shows up'); |
||||
|
} |
||||
|
}).addErrback(function () { |
||||
|
throw new Exception('could not read from '+BIG_FILE); |
||||
|
}); |
||||
|
} |
||||
|
readChunk(); |
||||
|
}).addErrback(function () { |
||||
|
throw new Exception('could not open '+BIG_FILE); |
||||
|
}); |
||||
|
|
||||
|
tryToKillEventLoop(); |
||||
|
|
||||
|
process.addListener("exit", function () { |
||||
|
assert.ok(pos > 10000); |
||||
|
}); |
Loading…
Reference in new issue