Merge remote-tracking branch 'ry/v0.6' into v0.6-merge
Conflicts: Makefile lib/zlib.js src/node.cc src/node.js
This commit is contained in:
commit
07be9fc3a6
13
lib/http.js
13
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);
|
||||||
req.emit('error', err);
|
if (req) {
|
||||||
// For Safety. Some additional errors might fire later on
|
req.emit('error', err);
|
||||||
// and we need to make sure we don't double-fire the error event.
|
// For Safety. Some additional errors might fire later on
|
||||||
req._hadError = true;
|
// and we need to make sure we don't double-fire the error event.
|
||||||
|
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) {
|
||||||
|
@ -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;
|
||||||
delete Module._cache[filename];
|
} finally {
|
||||||
throw err;
|
if (hadException) {
|
||||||
|
delete Module._cache[filename];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return module.exports;
|
return module.exports;
|
||||||
|
15
src/node.cc
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;
|
||||||
|
40
src/node.js
40
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++];
|
||||||
|
var callback = tock.callback;
|
||||||
try {
|
if (tock.domain) {
|
||||||
for (var i = 0; i < l; i++) {
|
if (tock.domain._disposed) continue;
|
||||||
var tock = q[i];
|
tock.domain.enter();
|
||||||
var callback = tock.callback;
|
}
|
||||||
if (tock.domain) {
|
callback();
|
||||||
if (tock.domain._disposed) continue;
|
if (tock.domain) {
|
||||||
tock.domain.enter();
|
tock.domain.exit();
|
||||||
}
|
|
||||||
callback();
|
|
||||||
if (tock.domain) tock.domain.exit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
|
||||||
if (i + 1 < l) {
|
nextTickQueue.splice(0, nextTickIndex);
|
||||||
nextTickQueue = q.slice(i + 1).concat(nextTickQueue);
|
nextTickIndex = 0;
|
||||||
}
|
|
||||||
if (nextTickQueue.length) {
|
|
||||||
process._needTickCallback();
|
|
||||||
}
|
|
||||||
throw e; // process.nextTick error, or 'error' event on first tick
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
process.nextTick = function(callback) {
|
process.nextTick = function(callback) {
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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]
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
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>:*
|
||||||
at Object.<anonymous> (*test*message*undefined_reference_in_new_context.js:*)
|
at Object.<anonymous> (*test*message*undefined_reference_in_new_context.js:*)
|
||||||
|
50
test/simple/test-http-client-timeout.js
Normal file
50
test/simple/test-http-client-timeout.js
Normal file
@ -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…
x
Reference in New Issue
Block a user