Browse Source

domain: the EventEmitter constructor is now always called in nodecore

v0.9.1-release
Andreas Madsen 13 years ago
committed by isaacs
parent
commit
1e0ce5d1bd
  1. 6
      lib/child_process.js
  2. 5
      lib/cluster.js
  3. 6
      lib/fs.js
  4. 14
      lib/http.js
  5. 6
      lib/net.js
  6. 4
      lib/readline.js
  7. 9
      lib/repl.js
  8. 6
      lib/tls.js
  9. 6
      lib/zlib.js

6
lib/child_process.js

@ -160,6 +160,8 @@ var handleConversion = {
// This object keep track of the socket there are sended // This object keep track of the socket there are sended
function SocketListSend(slave, key) { function SocketListSend(slave, key) {
EventEmitter.call(this);
var self = this; var self = this;
this.key = key; this.key = key;
@ -201,6 +203,8 @@ SocketListSend.prototype.update = function() {
// This object keep track of the socket there are received // This object keep track of the socket there are received
function SocketListReceive(slave, key) { function SocketListReceive(slave, key) {
EventEmitter.call(this);
var self = this; var self = this;
this.key = key; this.key = key;
@ -632,6 +636,8 @@ function maybeClose(subprocess) {
function ChildProcess() { function ChildProcess() {
EventEmitter.call(this);
var self = this; var self = this;
this._closesNeeded = 1; this._closesNeeded = 1;

5
lib/cluster.js

@ -41,7 +41,9 @@ if (process.env.NODE_DEBUG && /cluster/.test(process.env.NODE_DEBUG)) {
} }
// cluster object: // cluster object:
function cluster() {} function cluster() {
EventEmitter.call(this);
}
util.inherits(cluster, EventEmitter); util.inherits(cluster, EventEmitter);
var cluster = module.exports = new cluster(); var cluster = module.exports = new cluster();
@ -254,6 +256,7 @@ function toDecInt(value) {
// Create a worker object, that works both for master and worker // Create a worker object, that works both for master and worker
function Worker(customEnv) { function Worker(customEnv) {
if (!(this instanceof Worker)) return new Worker(); if (!(this instanceof Worker)) return new Worker();
EventEmitter.call(this);
var self = this; var self = this;
var env = process.env; var env = process.env;

6
lib/fs.js

@ -811,6 +811,8 @@ function errnoException(errorno, syscall) {
function FSWatcher() { function FSWatcher() {
EventEmitter.call(this);
var self = this; var self = this;
var FSEvent = process.binding('fs_event_wrap').FSEvent; var FSEvent = process.binding('fs_event_wrap').FSEvent;
this._handle = new FSEvent(); this._handle = new FSEvent();
@ -869,6 +871,8 @@ fs.watch = function(filename) {
// Stat Change Watchers // Stat Change Watchers
function StatWatcher() { function StatWatcher() {
EventEmitter.call(this);
var self = this; var self = this;
this._handle = new binding.StatWatcher(); this._handle = new binding.StatWatcher();
@ -1564,6 +1568,8 @@ WriteStream.prototype.destroySoon = WriteStream.prototype.end;
// SyncWriteStream is internal. DO NOT USE. // SyncWriteStream is internal. DO NOT USE.
// Temporary hack for process.stdout and process.stderr when piped to files. // Temporary hack for process.stdout and process.stderr when piped to files.
function SyncWriteStream(fd) { function SyncWriteStream(fd) {
Stream.call(this);
this.fd = fd; this.fd = fd;
this.writable = true; this.writable = true;
this.readable = false; this.readable = false;

14
lib/http.js

@ -21,7 +21,7 @@
var util = require('util'); var util = require('util');
var net = require('net'); var net = require('net');
var stream = require('stream'); var Stream = require('stream');
var url = require('url'); var url = require('url');
var EventEmitter = require('events').EventEmitter; var EventEmitter = require('events').EventEmitter;
var FreeList = require('freelist').FreeList; var FreeList = require('freelist').FreeList;
@ -263,7 +263,7 @@ function utcDate() {
/* Abstract base class for ServerRequest and ClientResponse. */ /* Abstract base class for ServerRequest and ClientResponse. */
function IncomingMessage(socket) { function IncomingMessage(socket) {
stream.Stream.call(this); Stream.call(this);
// TODO Remove one of these eventually. // TODO Remove one of these eventually.
this.socket = socket; this.socket = socket;
@ -290,7 +290,7 @@ function IncomingMessage(socket) {
this.statusCode = null; this.statusCode = null;
this.client = this.socket; this.client = this.socket;
} }
util.inherits(IncomingMessage, stream.Stream); util.inherits(IncomingMessage, Stream);
exports.IncomingMessage = IncomingMessage; exports.IncomingMessage = IncomingMessage;
@ -429,7 +429,7 @@ IncomingMessage.prototype._addHeaderLine = function(field, value) {
function OutgoingMessage() { function OutgoingMessage() {
stream.Stream.call(this); Stream.call(this);
this.output = []; this.output = [];
this.outputEncodings = []; this.outputEncodings = [];
@ -447,7 +447,7 @@ function OutgoingMessage() {
this.finished = false; this.finished = false;
} }
util.inherits(OutgoingMessage, stream.Stream); util.inherits(OutgoingMessage, Stream);
exports.OutgoingMessage = OutgoingMessage; exports.OutgoingMessage = OutgoingMessage;
@ -1022,6 +1022,8 @@ ServerResponse.prototype.writeHeader = function() {
// concerned with managing a connection pool. // concerned with managing a connection pool.
function Agent(options) { function Agent(options) {
EventEmitter.call(this);
var self = this; var self = this;
self.options = options || {}; self.options = options || {};
self.requests = {}; self.requests = {};
@ -1791,6 +1793,8 @@ exports._connectionListener = connectionListener;
function Client(port, host) { function Client(port, host) {
if (!(this instanceof Client)) return new Client(port, host); if (!(this instanceof Client)) return new Client(port, host);
EventEmitter.call(this);
host = host || 'localhost'; host = host || 'localhost';
port = port || 80; port = port || 80;
this.host = host; this.host = host;

6
lib/net.js

@ -20,7 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE. // USE OR OTHER DEALINGS IN THE SOFTWARE.
var events = require('events'); var events = require('events');
var stream = require('stream'); var Stream = require('stream');
var timers = require('timers'); var timers = require('timers');
var util = require('util'); var util = require('util');
var assert = require('assert'); var assert = require('assert');
@ -129,7 +129,7 @@ function initSocketHandle(self) {
function Socket(options) { function Socket(options) {
if (!(this instanceof Socket)) return new Socket(options); if (!(this instanceof Socket)) return new Socket(options);
stream.Stream.call(this); Stream.call(this);
if (typeof options == 'number') { if (typeof options == 'number') {
// Legacy interface. // Legacy interface.
@ -152,7 +152,7 @@ function Socket(options) {
this.allowHalfOpen = options && options.allowHalfOpen; this.allowHalfOpen = options && options.allowHalfOpen;
} }
} }
util.inherits(Socket, stream.Stream); util.inherits(Socket, Stream);
exports.Socket = Socket; exports.Socket = Socket;

4
lib/readline.js

@ -49,6 +49,8 @@ function Interface(input, output, completer, terminal) {
return new Interface(input, output, completer, terminal); return new Interface(input, output, completer, terminal);
} }
EventEmitter.call(this);
if (arguments.length === 1) { if (arguments.length === 1) {
// an options object was given // an options object was given
output = input.output; output = input.output;
@ -57,8 +59,6 @@ function Interface(input, output, completer, terminal) {
input = input.input; input = input.input;
} }
EventEmitter.call(this);
completer = completer || function() { return []; }; completer = completer || function() { return []; };
if (typeof completer !== 'function') { if (typeof completer !== 'function') {

9
lib/repl.js

@ -42,6 +42,7 @@
var util = require('util'); var util = require('util');
var inherits = require('util').inherits; var inherits = require('util').inherits;
var Stream = require('stream');
var vm = require('vm'); var vm = require('vm');
var path = require('path'); var path = require('path');
var fs = require('fs'); var fs = require('fs');
@ -79,6 +80,8 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) {
return new REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined); return new REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined);
} }
EventEmitter.call(this);
var options, input, output; var options, input, output;
if (typeof prompt == 'object') { if (typeof prompt == 'object') {
// an options object was given // an options object was given
@ -96,8 +99,6 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) {
options = {}; options = {};
} }
EventEmitter.call(this);
var self = this; var self = this;
self.useGlobal = !!useGlobal; self.useGlobal = !!useGlobal;
@ -376,6 +377,8 @@ REPLServer.prototype.displayPrompt = function(preserveCursor) {
// A stream to push an array into a REPL // A stream to push an array into a REPL
// used in REPLServer.complete // used in REPLServer.complete
function ArrayStream() { function ArrayStream() {
Stream.call(this);
this.run = function(data) { this.run = function(data) {
var self = this; var self = this;
data.forEach(function(line) { data.forEach(function(line) {
@ -383,7 +386,7 @@ function ArrayStream() {
}); });
} }
} }
util.inherits(ArrayStream, require('stream').Stream); util.inherits(ArrayStream, Stream);
ArrayStream.prototype.readable = true; ArrayStream.prototype.readable = true;
ArrayStream.prototype.writable = true; ArrayStream.prototype.writable = true;
ArrayStream.prototype.resume = function() {}; ArrayStream.prototype.resume = function() {};

6
lib/tls.js

@ -23,7 +23,7 @@ var crypto = require('crypto');
var util = require('util'); var util = require('util');
var net = require('net'); var net = require('net');
var events = require('events'); var events = require('events');
var stream = require('stream'); var Stream = require('stream');
var END_OF_FILE = 42; var END_OF_FILE = 42;
var assert = require('assert').ok; var assert = require('assert').ok;
var constants = require('constants'); var constants = require('constants');
@ -79,7 +79,7 @@ function convertNPNProtocols(NPNProtocols, out) {
// Base class of both CleartextStream and EncryptedStream // Base class of both CleartextStream and EncryptedStream
function CryptoStream(pair) { function CryptoStream(pair) {
stream.Stream.call(this); Stream.call(this);
this.pair = pair; this.pair = pair;
@ -91,7 +91,7 @@ function CryptoStream(pair) {
this._pendingCallbacks = []; this._pendingCallbacks = [];
this._pendingBytes = 0; this._pendingBytes = 0;
} }
util.inherits(CryptoStream, stream.Stream); util.inherits(CryptoStream, Stream);
CryptoStream.prototype.write = function(data /* , encoding, cb */) { CryptoStream.prototype.write = function(data /* , encoding, cb */) {

6
lib/zlib.js

@ -21,7 +21,7 @@
var binding = process.binding('zlib'); var binding = process.binding('zlib');
var util = require('util'); var util = require('util');
var stream = require('stream'); var Stream = require('stream');
var assert = require('assert').ok; var assert = require('assert').ok;
// zlib doesn't provide these, so kludge them in following the same // zlib doesn't provide these, so kludge them in following the same
@ -215,6 +215,8 @@ function Unzip(opts) {
// you call the .write() method. // you call the .write() method.
function Zlib(opts, mode) { function Zlib(opts, mode) {
Stream.call(this);
this._opts = opts = opts || {}; this._opts = opts = opts || {};
this._queue = []; this._queue = [];
this._processing = false; this._processing = false;
@ -296,7 +298,7 @@ function Zlib(opts, mode) {
var self = this; var self = this;
} }
util.inherits(Zlib, stream.Stream); util.inherits(Zlib, Stream);
Zlib.prototype.write = function write(chunk, cb) { Zlib.prototype.write = function write(chunk, cb) {
if (this._hadError) return true; if (this._hadError) return true;

Loading…
Cancel
Save