moved handle close to fork worker

This commit is contained in:
barisusakli
2014-11-27 14:09:01 -05:00
parent 5521e6143f
commit 785790c414
2 changed files with 14 additions and 10 deletions

View File

@@ -141,15 +141,6 @@ Loader.addClusterEvents = function(callback) {
case 'config:update':
Loader.notifyWorkers(message);
break;
case 'sticky-session:accept':
var _handle = handles[message.handleIndex];
if (_handle) {
_handle.close();
delete handles[message.handleIndex];
}
break;
}
}
});
@@ -229,6 +220,19 @@ function forkWorker(isPrimary) {
worker.process.stdout.pipe(output);
worker.process.stderr.pipe(output);
}
worker.on('message', function(message) {
if (!message || message.action !== 'sticky-session:accept') {
return;
}
var _handle = handles[message.handleIndex];
if (_handle) {
_handle.close();
delete handles[message.handleIndex];
}
});
}
function workerIndex(ip, numProcs) {

View File

@@ -151,8 +151,8 @@ if(nconf.get('ssl')) {
return;
}
server.emit('connection', connection);
process.send({action: 'sticky-session:accept', handleIndex: message.handleIndex});
server.emit('connection', connection);
});
}(WebServer));