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

Commit

Permalink
domain: the EventEmitter constructor is now always called in nodecore
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasMadsen authored and isaacs committed Jun 15, 2012
1 parent c6185c8 commit 1e0ce5d
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 19 deletions.
6 changes: 6 additions & 0 deletions lib/child_process.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -632,6 +636,8 @@ function maybeClose(subprocess) {


function ChildProcess() {
EventEmitter.call(this);

var self = this;

this._closesNeeded = 1;
Expand Down
5 changes: 4 additions & 1 deletion lib/cluster.js
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions lib/fs.js
Expand Up @@ -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();
Expand Down Expand Up @@ -869,6 +871,8 @@ fs.watch = function(filename) {
// Stat Change Watchers

function StatWatcher() {
EventEmitter.call(this);

var self = this;
this._handle = new binding.StatWatcher();

Expand Down Expand Up @@ -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;
Expand Down
14 changes: 9 additions & 5 deletions lib/http.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -429,7 +429,7 @@ IncomingMessage.prototype._addHeaderLine = function(field, value) {


function OutgoingMessage() {
stream.Stream.call(this);
Stream.call(this);

this.output = [];
this.outputEncodings = [];
Expand All @@ -447,7 +447,7 @@ function OutgoingMessage() {

this.finished = false;
}
util.inherits(OutgoingMessage, stream.Stream);
util.inherits(OutgoingMessage, Stream);


exports.OutgoingMessage = OutgoingMessage;
Expand Down Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lib/net.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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.
Expand All @@ -152,7 +152,7 @@ function Socket(options) {
this.allowHalfOpen = options && options.allowHalfOpen;
}
}
util.inherits(Socket, stream.Stream);
util.inherits(Socket, Stream);


exports.Socket = Socket;
Expand Down
4 changes: 2 additions & 2 deletions lib/readline.js
Expand Up @@ -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;
Expand All @@ -57,8 +59,6 @@ function Interface(input, output, completer, terminal) {
input = input.input;
}

EventEmitter.call(this);

completer = completer || function() { return []; };

if (typeof completer !== 'function') {
Expand Down
9 changes: 6 additions & 3 deletions lib/repl.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand All @@ -96,8 +99,6 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) {
options = {};
}

EventEmitter.call(this);

var self = this;

self.useGlobal = !!useGlobal;
Expand Down Expand Up @@ -376,14 +377,16 @@ 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) {
self.emit('data', line + '\n');
});
}
}
util.inherits(ArrayStream, require('stream').Stream);
util.inherits(ArrayStream, Stream);
ArrayStream.prototype.readable = true;
ArrayStream.prototype.writable = true;
ArrayStream.prototype.resume = function() {};
Expand Down
6 changes: 3 additions & 3 deletions lib/tls.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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;

Expand All @@ -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 */) {
Expand Down
6 changes: 4 additions & 2 deletions lib/zlib.js
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1e0ce5d

Please sign in to comment.