From 1a2696f10a55f79cf5347066630da37503889615 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 7 Sep 2009 14:20:41 +0200 Subject: [PATCH] Almost completely remove onExit and onLoad. They were deprecated in 723c7d9f7c4e5ba9600adae95bd481fad70a3d60 and 31265be4a6584ff1b9a1ed0dedb5bc6c2f1c2e56. Still retaining error message. --- src/node.js | 42 +++++-------------------------- test/mjsunit/test-tcp-throttle.js | 1 + 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/src/node.js b/src/node.js index 3986f12b9a..f6d0a4aa4e 100644 --- a/src/node.js +++ b/src/node.js @@ -158,16 +158,14 @@ node.Module.prototype.loadScript = function (callback) { self.onLoad = self.target.__onLoad; self.onExit = self.target.__onExit; if (self.onLoad || self.onExit) { - node.stdio.writeError( "(node) onLoad is depreciated it will be " - + "removed in the future. Don't want it to " - + "leave? Discuss on mailing list.\n" + node.stdio.writeError( "(node) onLoad and onExit have been removed. " + + " module load is synchronous so onLoad is unnecessary" + + " Use process.addListener('exit') for onExit. " ); + node.exit(1); } self.waitChildrenLoad(function () { - if (self.onLoad) { - self.onLoad(); - } self.loaded = true; loadPromise.emitSuccess([self.target]); }); @@ -203,32 +201,6 @@ node.Module.prototype.waitChildrenLoad = function (callback) { if (children.length == nloaded && callback) callback(); }; -node.Module.prototype.exitChildren = function (callback) { - var children = this.children; - if (children.length == 0 && callback) callback(); - var nexited = 0; - for (var i = 0; i < children.length; i++) { - children[i].exit(function () { - nexited += 1; - if (nexited == children.length && callback) callback(); - }); - } -}; - -node.Module.prototype.exit = function (callback) { - var self = this; - - if (self.exited) { - throw "Module '" + self.filename + "' is already exited."; - } - - this.exitChildren(function () { - if (self.onExit) self.onExit(); - self.exited = true; - if (callback) callback(); - }); -}; - (function () { // Load the root module--the command line argument. var root_module = new node.Module({ @@ -239,9 +211,7 @@ node.Module.prototype.exit = function (callback) { root_module.load(); node.exit = function (code) { - root_module.exit(function () { - process.emit("exit"); - node.reallyExit(code); - }); + process.emit("exit"); + node.reallyExit(code); }; }()); diff --git a/test/mjsunit/test-tcp-throttle.js b/test/mjsunit/test-tcp-throttle.js index f7d1b8ecd6..a064411744 100644 --- a/test/mjsunit/test-tcp-throttle.js +++ b/test/mjsunit/test-tcp-throttle.js @@ -63,4 +63,5 @@ client.addListener("eof", function () { process.addListener("exit", function () { assertEquals(N, recv.length); + node.debug("Exit"); });