Browse Source

Merge remote-tracking branch 'ry/v0.6' into v0.6-merge

Conflicts:
	Makefile
	lib/zlib.js
	src/node.cc
	src/node.js
v0.9.1-release
isaacs 13 years ago
parent
commit
07be9fc3a6
  1. 5
      lib/http.js
  2. 9
      lib/module.js
  3. 15
      src/node.cc
  4. 28
      src/node.js
  5. 4
      test/message/stack_overflow.out
  6. 6
      test/message/throw_custom_error.out
  7. 6
      test/message/throw_non_error.out
  8. 4
      test/message/undefined_reference_in_new_context.out
  9. 50
      test/simple/test-http-client-timeout.js

5
lib/http.js

@ -1296,12 +1296,14 @@ ClientRequest.prototype.onSocket = function(socket) {
// Setup 'drain' propogation. // Setup 'drain' propogation.
httpSocketSetup(socket); httpSocketSetup(socket);
var errorListener = function(err) { function errorListener(err) {
debug('HTTP SOCKET ERROR: ' + err.message + '\n' + err.stack); debug('HTTP SOCKET ERROR: ' + err.message + '\n' + err.stack);
if (req) {
req.emit('error', err); req.emit('error', err);
// For Safety. Some additional errors might fire later on // For Safety. Some additional errors might fire later on
// and we need to make sure we don't double-fire the error event. // and we need to make sure we don't double-fire the error event.
req._hadError = true; req._hadError = true;
}
if (parser) { if (parser) {
parser.finish(); parser.finish();
freeParser(parser, req); freeParser(parser, req);
@ -1515,7 +1517,6 @@ ClientRequest.prototype.setTimeout = function(msecs, callback) {
var self = this; var self = this;
function emitTimeout() { function emitTimeout() {
self.emit('timeout'); self.emit('timeout');
self.destroy(new Error('timeout'));
} }
if (this.socket && this.socket.writable) { if (this.socket && this.socket.writable) {

9
lib/module.js

@ -305,11 +305,16 @@ Module._load = function(request, parent, isMain) {
} }
Module._cache[filename] = module; Module._cache[filename] = module;
var hadException = true;
try { try {
module.load(filename); module.load(filename);
} catch (err) { hadException = false;
} finally {
if (hadException) {
delete Module._cache[filename]; delete Module._cache[filename];
throw err; }
} }
return module.exports; return module.exports;

15
src/node.cc

@ -90,7 +90,6 @@ extern char **environ;
namespace node { namespace node {
static Persistent<Object> process; static Persistent<Object> process;
static Persistent<String> errno_symbol; static Persistent<String> errno_symbol;
@ -256,9 +255,7 @@ static void Spin(uv_idle_t* handle, int status) {
Tick(); Tick();
} }
static void StartTickSpinner() {
static Handle<Value> NeedTickCallback(const Arguments& args) {
HandleScope scope;
need_tick_cb = true; need_tick_cb = true;
// TODO: this tick_spinner shouldn't be necessary. An ev_prepare should be // TODO: this tick_spinner shouldn't be necessary. An ev_prepare should be
// sufficent, the problem is only in the case of the very last "tick" - // sufficent, the problem is only in the case of the very last "tick" -
@ -269,9 +266,12 @@ static Handle<Value> NeedTickCallback(const Arguments& args) {
uv_idle_start(&tick_spinner, Spin); uv_idle_start(&tick_spinner, Spin);
uv_ref(uv_default_loop()); uv_ref(uv_default_loop());
} }
return Undefined();
} }
static Handle<Value> NeedTickCallback(const Arguments& args) {
StartTickSpinner();
return Undefined();
}
static void PrepareTick(uv_prepare_t* handle, int status) { static void PrepareTick(uv_prepare_t* handle, int status) {
assert(handle == &prepare_tick_watcher); assert(handle == &prepare_tick_watcher);
@ -1834,11 +1834,15 @@ void FatalException(TryCatch &try_catch) {
TryCatch event_try_catch; TryCatch event_try_catch;
emit->Call(process, 2, event_argv); emit->Call(process, 2, event_argv);
if (event_try_catch.HasCaught()) { if (event_try_catch.HasCaught()) {
// the uncaught exception event threw, so we must exit. // the uncaught exception event threw, so we must exit.
ReportException(event_try_catch, true); ReportException(event_try_catch, true);
exit(1); exit(1);
} }
// This makes sure uncaught exceptions don't interfere with process.nextTick
StartTickSpinner();
} }
@ -2288,7 +2292,6 @@ void Load(Handle<Object> process_l) {
// source code.) // source code.)
// The node.js file returns a function 'f' // The node.js file returns a function 'f'
atexit(AtExit); atexit(AtExit);
TryCatch try_catch; TryCatch try_catch;

28
src/node.js

@ -219,35 +219,27 @@
startup.processNextTick = function() { startup.processNextTick = function() {
var nextTickQueue = []; var nextTickQueue = [];
var nextTickIndex = 0;
process._tickCallback = function() { process._tickCallback = function() {
var l = nextTickQueue.length; var nextTickLength = nextTickQueue.length;
if (l === 0) return; if (nextTickLength === 0) return;
var q = nextTickQueue; while (nextTickIndex < nextTickLength) {
nextTickQueue = []; var tock = nextTickQueue[nextTickIndex++];
try {
for (var i = 0; i < l; i++) {
var tock = q[i];
var callback = tock.callback; var callback = tock.callback;
if (tock.domain) { if (tock.domain) {
if (tock.domain._disposed) continue; if (tock.domain._disposed) continue;
tock.domain.enter(); tock.domain.enter();
} }
callback(); callback();
if (tock.domain) tock.domain.exit(); if (tock.domain) {
} tock.domain.exit();
}
catch (e) {
if (i + 1 < l) {
nextTickQueue = q.slice(i + 1).concat(nextTickQueue);
}
if (nextTickQueue.length) {
process._needTickCallback();
} }
throw e; // process.nextTick error, or 'error' event on first tick
} }
nextTickQueue.splice(0, nextTickIndex);
nextTickIndex = 0;
}; };
process.nextTick = function(callback) { process.nextTick = function(callback) {

4
test/message/stack_overflow.out

@ -1,6 +1,6 @@
before before
node.js:* *test*message*stack_overflow.js:31
throw e; // process.nextTick error, or 'error' event on first tick function stackOverflow() {
^ ^
RangeError: Maximum call stack size exceeded RangeError: Maximum call stack size exceeded

6
test/message/throw_custom_error.out

@ -1,6 +1,6 @@
before before
node.js:* *test*message*throw_custom_error.js:31
throw e; // process.nextTick error, or 'error' event on first tick throw ({ name: 'MyCustomError', message: 'This is a custom message' });
^ ^
MyCustomError: This is a custom message MyCustomError: This is a custom message

6
test/message/throw_non_error.out

@ -1,6 +1,6 @@
before before
node.js:* */test/message/throw_non_error.js:31
throw e; // process.nextTick error, or 'error' event on first tick throw ({ foo: 'bar' });
^ ^
[object Object] [object Object]

4
test/message/undefined_reference_in_new_context.out

@ -1,7 +1,7 @@
before before
node.js:* *test*message*undefined_reference_in_new_context.js:34
throw e; // process.nextTick error, or 'error' event on first tick script.runInNewContext();
^ ^
ReferenceError: foo is not defined ReferenceError: foo is not defined
at evalmachine.<anonymous>:* at evalmachine.<anonymous>:*

50
test/simple/test-http-client-timeout.js

@ -0,0 +1,50 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');
var assert = require('assert');
var http = require('http');
var options = {
method: 'GET',
port: common.PORT,
host: '127.0.0.1',
path: '/'
};
var server = http.createServer(function(req, res) {
// this space intentionally left blank
});
server.listen(options.port, options.host, function() {
var req = http.request(options, function(res) {
// this space intentionally left blank
});
req.on('close', function() {
server.close();
});
function destroy() {
req.destroy();
}
req.setTimeout(1, destroy);
req.on('error', destroy);
req.end();
});
Loading…
Cancel
Save