Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
jslint
Fixes #2306
  • Loading branch information
AndreasMadsen authored and ry committed Dec 16, 2011
1 parent b9049d2 commit a599aeb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
18 changes: 8 additions & 10 deletions lib/child_process.js
Expand Up @@ -25,7 +25,6 @@ var Process = process.binding('process_wrap').Process;
var inherits = require('util').inherits;
var constants; // if (!constants) constants = process.binding('constants');

var LF = '\n'.charCodeAt(0);
var Pipe;


Expand Down Expand Up @@ -76,8 +75,8 @@ function setupChannel(target, channel) {

if (isWindows) {
var setSimultaneousAccepts = function(handle) {
var simultaneousAccepts = (process.env.NODE_MANY_ACCEPTS
&& process.env.NODE_MANY_ACCEPTS != '0') ? true : false;
var simultaneousAccepts = (process.env.NODE_MANY_ACCEPTS &&
process.env.NODE_MANY_ACCEPTS != '0') ? true : false;

if (handle._simultaneousAccepts != simultaneousAccepts) {
handle.setSimultaneousAccepts(simultaneousAccepts);
Expand All @@ -101,7 +100,7 @@ function setupChannel(target, channel) {
var message = JSON.parse(json);

target.emit('message', message, recvHandle);
start = i+1;
start = i + 1;
}
jsonBuffer = jsonBuffer.slice(start);

Expand All @@ -112,7 +111,7 @@ function setupChannel(target, channel) {
};

target.send = function(message, sendHandle) {
if (!target._channel) throw new Error("channel closed");
if (!target._channel) throw new Error('channel closed');

// For overflow protection don't write if channel queue is too deep.
if (channel.writeQueueSize > 1024 * 1024) {
Expand All @@ -129,7 +128,7 @@ function setupChannel(target, channel) {
var writeReq = channel.write(buffer, 0, buffer.length, sendHandle);

if (!writeReq) {
throw new Error(errno + " cannot write to IPC channel.");
throw new Error(errno + 'cannot write to IPC channel.');
}

writeReq.oncomplete = nop;
Expand All @@ -151,16 +150,16 @@ exports.fork = function(modulePath, args, options) {
args.unshift(modulePath);

if (options.stdinStream) {
throw new Error("stdinStream not allowed for fork()");
throw new Error('stdinStream not allowed for fork()');
}

if (options.customFds) {
throw new Error("customFds not allowed for fork()");
throw new Error('customFds not allowed for fork()');
}

// Leave stdin open for the IPC channel. stdout and stderr should be the
// same as the parent's.
options.customFds = [ -1, 1, 2 ];
options.customFds = [-1, 1, 2];

// Just need to set this - child process won't actually use the fd.
// For backwards compat - this can be changed to 'NODE_CHANNEL' before v0.6.
Expand Down Expand Up @@ -331,7 +330,6 @@ var spawn = exports.spawn = function(file, args, options) {

var env = (options ? options.env : null) || process.env;
var envPairs = [];
var keys = Object.keys(env);
for (var key in env) {
envPairs.push(key + '=' + env[key]);
}
Expand Down
26 changes: 13 additions & 13 deletions lib/cluster.js
Expand Up @@ -81,11 +81,11 @@ function startMaster() {
// Quickly try to kill all the workers.
// TODO: be session leader - will cause auto SIGHUP to the children.
eachWorker(function(worker) {
debug("kill worker " + worker.pid);
debug('kill worker ' + worker.pid);
worker.kill();
})
});

console.error("Exception in cluster master process: " +
console.error('Exception in cluster master process: ' +
e.message + '\n' + e.stack);
process.exit(1);
});
Expand All @@ -96,21 +96,21 @@ function handleWorkerMessage(worker, message) {
// This can only be called from the master.
assert(cluster.isMaster);

debug("recv " + JSON.stringify(message));
debug('recv ' + JSON.stringify(message));

switch (message.cmd) {
case 'online':
debug("Worker " + worker.pid + " online");
debug('Worker ' + worker.pid + ' online');
worker.online = true;
break;

case 'queryServer':
var key = message.address + ":" +
message.port + ":" +
var key = message.address + ':' +
message.port + ':' +
message.addressType;
var response = { _queryId: message._queryId };

if (key in servers == false) {
if (!(key in servers)) {
// Create a new server.
debug('create new server ' + key);
servers[key] = net._createServerHandle(message.address,
Expand All @@ -136,7 +136,7 @@ function eachWorker(cb) {
cb(workers[id]);
}
}
};
}


cluster.fork = function() {
Expand Down Expand Up @@ -176,19 +176,19 @@ cluster.fork = function() {
// Internal function. Called from src/node.js when worker process starts.
cluster._startWorker = function() {
assert(cluster.isWorker);
workerId = parseInt(process.env.NODE_WORKER_ID);
workerId = parseInt(process.env.NODE_WORKER_ID, 10);

queryMaster({ cmd: 'online' });

// Make callbacks from queryMaster()
process.on('message', function(msg, handle) {
debug("recv " + JSON.stringify(msg));
debug('recv ' + JSON.stringify(msg));
if (msg._queryId && msg._queryId in queryCallbacks) {
var cb = queryCallbacks[msg._queryId];
if (typeof cb == 'function') {
cb(msg, handle);
}
delete queryCallbacks[msg._queryId]
delete queryCallbacks[msg._queryId];
}
});
};
Expand Down Expand Up @@ -219,7 +219,7 @@ cluster._getServer = function(address, port, addressType, cb) {
assert(cluster.isWorker);

queryMaster({
cmd: "queryServer",
cmd: 'queryServer',
address: address,
port: port,
addressType: addressType
Expand Down

0 comments on commit a599aeb

Please sign in to comment.