Skip to content

Commit

Permalink
Merge efbf407 into 309ed42
Browse files Browse the repository at this point in the history
  • Loading branch information
bttmly committed Feb 14, 2017
2 parents 309ed42 + efbf407 commit f0378ae
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions index.js
Expand Up @@ -23,16 +23,7 @@ function addShutdown(server) {
}
};

server.on('request', function(req, res) {
req.socket._isIdle = false;

res.on('finish', function() {
req.socket._isIdle = true;
destroy(req.socket);
});
});

server.on('connection', function(socket) {
function onConnection(socket) {
var id = connectionCounter++;
socket._isIdle = true;
socket._connectionId = id;
Expand All @@ -41,8 +32,20 @@ function addShutdown(server) {
socket.on('close', function() {
delete connections[id];
});
};

server.on('request', function(req, res) {
req.socket._isIdle = false;

res.on('finish', function() {
req.socket._isIdle = true;
destroy(req.socket);
});
});

server.on('connection', onConnection);
server.on('secureConnection', onConnection);

function shutdown(force, cb) {
isShuttingDown = true;
server.close(function(err) {
Expand Down

0 comments on commit f0378ae

Please sign in to comment.