From dce86828273ee2bca41fe2bf41e62ba044544177 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 19 Mar 2012 13:34:12 -0700 Subject: [PATCH] cluster: English language fixing --- doc/api/cluster.markdown | 13 +++++++------ lib/cluster.js | 38 +++++++++++++++++++------------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/doc/api/cluster.markdown b/doc/api/cluster.markdown index b7cfee4ce8..be2e396c1d 100644 --- a/doc/api/cluster.markdown +++ b/doc/api/cluster.markdown @@ -123,11 +123,12 @@ where the 'listening' event is emitted. * `worker` {Worker object} When a workers IPC channel has disconnected this event is emitted. This will happen -when the worker die, usually after calling `.destroy()`. +when the worker dies, usually after calling `.destroy()`. -But also when calling `.disconnect()`, in this case it is possible there is delay -between the `disconnect` and `death` and the event can be used to detect if the -process is stuck in a cleanup or if there are long living connection. +When calling `.disconnect()`, there may be a delay between the +`disconnect` and `death` events. This event can be used to detect if +the process is stuck in a cleanup or if there are long-living +connections. cluster.on('disconnect', function(worker) { console.log('The worker #' + worker.uniqueID + ' has disconnected'); @@ -198,11 +199,11 @@ This object is not supposed to be change or set manually. * `callback` {Function} called when all workers are disconnected and handlers are closed -When calling this method all workers will commit a graceful suicide. When they are +When calling this method, all workers will commit a graceful suicide. When they are disconnected all internal handlers will be closed, allowing the master process to die graceful if no other event is waiting. -The method takes an optional callback argument there will be called when finished. +The method takes an optional callback argument which will be called when finished. ## cluster.workers diff --git a/lib/cluster.js b/lib/cluster.js index 686d05d3bd..c47270585e 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -51,7 +51,7 @@ var ids = 0; var serverHandlers = {}; // Used in the worker: -var serverLisenters = {}; +var serverListeners = {}; var queryIds = 0; var queryCallbacks = {}; @@ -153,7 +153,7 @@ function handleResponse(outMessage, outHandle, inMessage, inHandle, worker) { } // Handle messages from both master and workers -var messageHandingObject = {}; +var messageHandler = {}; function handleMessage(worker, inMessage, inHandle) { //Remove internal prefix @@ -161,14 +161,14 @@ function handleMessage(worker, inMessage, inHandle) { message.cmd = inMessage.cmd.substr(INTERNAL_PREFIX.length); var respondUsed = false; - var respond = function(outMessage, outHandler) { + function respond(outMessage, outHandler) { respondUsed = true; handleResponse(outMessage, outHandler, inMessage, inHandle, worker); - }; + } // Run handler if it exist - if (messageHandingObject[message.cmd]) { - messageHandingObject[message.cmd](message, worker, respond); + if (messageHandler[message.cmd]) { + messageHandler[message.cmd](message, worker, respond); } // Send respond if it wasn't done @@ -181,7 +181,7 @@ function handleMessage(worker, inMessage, inHandle) { if (cluster.isMaster) { // Handle online messages from workers - messageHandingObject.online = function(message, worker) { + messageHandler.online = function(message, worker) { worker.state = 'online'; debug('Worker ' + worker.process.pid + ' online'); worker.emit('online', worker); @@ -189,7 +189,7 @@ if (cluster.isMaster) { }; // Handle queryServer messages form workers - messageHandingObject.queryServer = function(message, worker, send) { + messageHandler.queryServer = function(message, worker, send) { // This sequence of infomation is unique to the connection but not // to the worker @@ -208,7 +208,7 @@ if (cluster.isMaster) { }; // Handle listening messages from workers - messageHandingObject.listening = function(message, worker) { + messageHandler.listening = function(message, worker) { worker.state = 'listening'; @@ -226,7 +226,7 @@ if (cluster.isMaster) { }; // Handle suicide messages from workers - messageHandingObject.suicide = function(message, worker) { + messageHandler.suicide = function(message, worker) { worker.suicide = true; }; @@ -236,7 +236,7 @@ if (cluster.isMaster) { else if (cluster.isWorker) { // Handle worker.disconnect from master - messageHandingObject.disconnect = function(message, worker) { + messageHandler.disconnect = function(message, worker) { worker.disconnect(); }; } @@ -412,12 +412,12 @@ if (cluster.isMaster) { this.suicide = true; // keep track of open servers - var servers = Object.keys(serverLisenters).length; + var servers = Object.keys(serverListeners).length; var progress = new ProgressTracker(servers, function() { // there are no more servers open so we will close the IPC channel. - // Closeing the IPC channel will emit emit a disconnect event + // Closing the IPC channel will emit a disconnect event // in both master and worker on the process object. - // This event will be handled by prepearDeath. + // This event will be handled by prepareDeath. self.process.disconnect(); }); @@ -428,10 +428,10 @@ if (cluster.isMaster) { // in case there are no servers progress.check(); - // closeing all servers graceful + // closing all servers gracefully var server; - for (var key in serverLisenters) { - server = serverLisenters[key]; + for (var key in serverListeners) { + server = serverListeners[key]; // in case the server is closed we wont close it again if (server._handle === null) { @@ -491,7 +491,7 @@ cluster._setupWorker = function() { // Get worker class var worker = cluster.worker = new Worker(); - // when the worker is disconnected from parent accidently + // when the worker is disconnected from parent accidentally // we will terminate the worker process.once('disconnect', function() { if (worker.suicide !== true) { @@ -511,7 +511,7 @@ cluster._getServer = function(tcpSelf, address, port, addressType, cb) { // Store tcp instance for later use var key = [address, port, addressType].join(':'); - serverLisenters[key] = tcpSelf; + serverListeners[key] = tcpSelf; // Send a listening message to the master tcpSelf.once('listening', function() {