mirror of https://github.com/lukechilds/node.git
Browse Source
Improve performance of process._getActiveHandles by sending handles in batches to JS to be set on the passed Array. Add test to check proper active handles are returned. Alter implementation of GetActiveRequests to match GetActiveHandles' implementation. PR-URL: https://github.com/nodejs/node/pull/3780 Reviewed-By: Fedor Indutny <fedor@indutny.com>process-exit-stdio-flushing
Trevor Norris
9 years ago
2 changed files with 66 additions and 18 deletions
@ -0,0 +1,44 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const common = require('../common'); |
||||
|
const assert = require('assert'); |
||||
|
const net = require('net'); |
||||
|
const NUM = 8; |
||||
|
const connections = []; |
||||
|
const clients = []; |
||||
|
var clients_counter = 0; |
||||
|
|
||||
|
const server = net.createServer(function listener(c) { |
||||
|
connections.push(c); |
||||
|
}).listen(common.PORT, function makeConnections() { |
||||
|
for (var i = 0; i < NUM; i++) { |
||||
|
net.connect(common.PORT, function connected() { |
||||
|
clientConnected(this); |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
function clientConnected(client) { |
||||
|
clients.push(client); |
||||
|
if (++clients_counter >= NUM) |
||||
|
checkAll(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
function checkAll() { |
||||
|
const handles = process._getActiveHandles(); |
||||
|
|
||||
|
clients.forEach(function(item) { |
||||
|
assert.ok(handles.indexOf(item) > -1); |
||||
|
item.destroy(); |
||||
|
}); |
||||
|
|
||||
|
connections.forEach(function(item) { |
||||
|
assert.ok(handles.indexOf(item) > -1); |
||||
|
item.end(); |
||||
|
}); |
||||
|
|
||||
|
assert.ok(handles.indexOf(server) > -1); |
||||
|
server.close(); |
||||
|
} |
Loading…
Reference in new issue