From 1e0ce5d1bdf364bf6eca821635e3ae8e65807667 Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Tue, 12 Jun 2012 21:53:08 +0200 Subject: [PATCH] domain: the EventEmitter constructor is now always called in nodecore --- lib/child_process.js | 6 ++++++ lib/cluster.js | 5 ++++- lib/fs.js | 6 ++++++ lib/http.js | 14 +++++++++----- lib/net.js | 6 +++--- lib/readline.js | 4 ++-- lib/repl.js | 9 ++++++--- lib/tls.js | 6 +++--- lib/zlib.js | 6 ++++-- 9 files changed, 43 insertions(+), 19 deletions(-) diff --git a/lib/child_process.js b/lib/child_process.js index 48fc5de81..6e0912ee2 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -160,6 +160,8 @@ var handleConversion = { // This object keep track of the socket there are sended function SocketListSend(slave, key) { + EventEmitter.call(this); + var self = this; this.key = key; @@ -201,6 +203,8 @@ SocketListSend.prototype.update = function() { // This object keep track of the socket there are received function SocketListReceive(slave, key) { + EventEmitter.call(this); + var self = this; this.key = key; @@ -632,6 +636,8 @@ function maybeClose(subprocess) { function ChildProcess() { + EventEmitter.call(this); + var self = this; this._closesNeeded = 1; diff --git a/lib/cluster.js b/lib/cluster.js index b25baed69..f62e8abd1 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -41,7 +41,9 @@ if (process.env.NODE_DEBUG && /cluster/.test(process.env.NODE_DEBUG)) { } // cluster object: -function cluster() {} +function cluster() { + EventEmitter.call(this); +} util.inherits(cluster, EventEmitter); var cluster = module.exports = new cluster(); @@ -254,6 +256,7 @@ function toDecInt(value) { // Create a worker object, that works both for master and worker function Worker(customEnv) { if (!(this instanceof Worker)) return new Worker(); + EventEmitter.call(this); var self = this; var env = process.env; diff --git a/lib/fs.js b/lib/fs.js index a633154fe..19456fd33 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -811,6 +811,8 @@ function errnoException(errorno, syscall) { function FSWatcher() { + EventEmitter.call(this); + var self = this; var FSEvent = process.binding('fs_event_wrap').FSEvent; this._handle = new FSEvent(); @@ -869,6 +871,8 @@ fs.watch = function(filename) { // Stat Change Watchers function StatWatcher() { + EventEmitter.call(this); + var self = this; this._handle = new binding.StatWatcher(); @@ -1564,6 +1568,8 @@ WriteStream.prototype.destroySoon = WriteStream.prototype.end; // SyncWriteStream is internal. DO NOT USE. // Temporary hack for process.stdout and process.stderr when piped to files. function SyncWriteStream(fd) { + Stream.call(this); + this.fd = fd; this.writable = true; this.readable = false; diff --git a/lib/http.js b/lib/http.js index 92e00049a..21359cad4 100644 --- a/lib/http.js +++ b/lib/http.js @@ -21,7 +21,7 @@ var util = require('util'); var net = require('net'); -var stream = require('stream'); +var Stream = require('stream'); var url = require('url'); var EventEmitter = require('events').EventEmitter; var FreeList = require('freelist').FreeList; @@ -263,7 +263,7 @@ function utcDate() { /* Abstract base class for ServerRequest and ClientResponse. */ function IncomingMessage(socket) { - stream.Stream.call(this); + Stream.call(this); // TODO Remove one of these eventually. this.socket = socket; @@ -290,7 +290,7 @@ function IncomingMessage(socket) { this.statusCode = null; this.client = this.socket; } -util.inherits(IncomingMessage, stream.Stream); +util.inherits(IncomingMessage, Stream); exports.IncomingMessage = IncomingMessage; @@ -429,7 +429,7 @@ IncomingMessage.prototype._addHeaderLine = function(field, value) { function OutgoingMessage() { - stream.Stream.call(this); + Stream.call(this); this.output = []; this.outputEncodings = []; @@ -447,7 +447,7 @@ function OutgoingMessage() { this.finished = false; } -util.inherits(OutgoingMessage, stream.Stream); +util.inherits(OutgoingMessage, Stream); exports.OutgoingMessage = OutgoingMessage; @@ -1022,6 +1022,8 @@ ServerResponse.prototype.writeHeader = function() { // concerned with managing a connection pool. function Agent(options) { + EventEmitter.call(this); + var self = this; self.options = options || {}; self.requests = {}; @@ -1791,6 +1793,8 @@ exports._connectionListener = connectionListener; function Client(port, host) { if (!(this instanceof Client)) return new Client(port, host); + EventEmitter.call(this); + host = host || 'localhost'; port = port || 80; this.host = host; diff --git a/lib/net.js b/lib/net.js index 95c3508d9..2975ad4aa 100644 --- a/lib/net.js +++ b/lib/net.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. var events = require('events'); -var stream = require('stream'); +var Stream = require('stream'); var timers = require('timers'); var util = require('util'); var assert = require('assert'); @@ -129,7 +129,7 @@ function initSocketHandle(self) { function Socket(options) { if (!(this instanceof Socket)) return new Socket(options); - stream.Stream.call(this); + Stream.call(this); if (typeof options == 'number') { // Legacy interface. @@ -152,7 +152,7 @@ function Socket(options) { this.allowHalfOpen = options && options.allowHalfOpen; } } -util.inherits(Socket, stream.Stream); +util.inherits(Socket, Stream); exports.Socket = Socket; diff --git a/lib/readline.js b/lib/readline.js index 8adc2c145..e6b579277 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -49,6 +49,8 @@ function Interface(input, output, completer, terminal) { return new Interface(input, output, completer, terminal); } + EventEmitter.call(this); + if (arguments.length === 1) { // an options object was given output = input.output; @@ -57,8 +59,6 @@ function Interface(input, output, completer, terminal) { input = input.input; } - EventEmitter.call(this); - completer = completer || function() { return []; }; if (typeof completer !== 'function') { diff --git a/lib/repl.js b/lib/repl.js index a78a467e6..4eac059e3 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -42,6 +42,7 @@ var util = require('util'); var inherits = require('util').inherits; +var Stream = require('stream'); var vm = require('vm'); var path = require('path'); var fs = require('fs'); @@ -79,6 +80,8 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) { return new REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined); } + EventEmitter.call(this); + var options, input, output; if (typeof prompt == 'object') { // an options object was given @@ -96,8 +99,6 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) { options = {}; } - EventEmitter.call(this); - var self = this; self.useGlobal = !!useGlobal; @@ -376,6 +377,8 @@ REPLServer.prototype.displayPrompt = function(preserveCursor) { // A stream to push an array into a REPL // used in REPLServer.complete function ArrayStream() { + Stream.call(this); + this.run = function(data) { var self = this; 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.writable = true; ArrayStream.prototype.resume = function() {}; diff --git a/lib/tls.js b/lib/tls.js index 439e83e4a..0b3ff0174 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -23,7 +23,7 @@ var crypto = require('crypto'); var util = require('util'); var net = require('net'); var events = require('events'); -var stream = require('stream'); +var Stream = require('stream'); var END_OF_FILE = 42; var assert = require('assert').ok; var constants = require('constants'); @@ -79,7 +79,7 @@ function convertNPNProtocols(NPNProtocols, out) { // Base class of both CleartextStream and EncryptedStream function CryptoStream(pair) { - stream.Stream.call(this); + Stream.call(this); this.pair = pair; @@ -91,7 +91,7 @@ function CryptoStream(pair) { this._pendingCallbacks = []; this._pendingBytes = 0; } -util.inherits(CryptoStream, stream.Stream); +util.inherits(CryptoStream, Stream); CryptoStream.prototype.write = function(data /* , encoding, cb */) { diff --git a/lib/zlib.js b/lib/zlib.js index a8a79d2a6..f05f6d139 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -21,7 +21,7 @@ var binding = process.binding('zlib'); var util = require('util'); -var stream = require('stream'); +var Stream = require('stream'); var assert = require('assert').ok; // zlib doesn't provide these, so kludge them in following the same @@ -215,6 +215,8 @@ function Unzip(opts) { // you call the .write() method. function Zlib(opts, mode) { + Stream.call(this); + this._opts = opts = opts || {}; this._queue = []; this._processing = false; @@ -296,7 +298,7 @@ function Zlib(opts, mode) { var self = this; } -util.inherits(Zlib, stream.Stream); +util.inherits(Zlib, Stream); Zlib.prototype.write = function write(chunk, cb) { if (this._hadError) return true; -- 2.34.1