Merge remote-tracking branch 'ry/v0.6' into v0.6-merge
authorisaacs <i@izs.me>
Wed, 9 May 2012 22:12:13 +0000 (15:12 -0700)
committerisaacs <i@izs.me>
Wed, 9 May 2012 22:12:13 +0000 (15:12 -0700)
Conflicts:
Makefile
lib/zlib.js
src/node.cc
src/node.js

1  2 
lib/http.js
lib/module.js
src/node.cc
src/node.js
test/message/throw_custom_error.out
test/message/throw_non_error.out
test/message/undefined_reference_in_new_context.out

diff --cc lib/http.js
@@@ -1284,24 -1154,18 +1284,26 @@@ ClientRequest.prototype.onSocket = func
      parser.incoming = null;
      req.parser = parser;
  
 +    // Propagate headers limit from request object to parser
 +    if (typeof req.maxHeadersCount === 'number') {
 +      parser.maxHeaderPairs = req.maxHeadersCount << 1;
 +    } else {
 +      // Set default value because parser may be reused from FreeList
 +      parser.maxHeaderPairs = 2000;
 +    }
 +
      socket._httpMessage = req;
 -    // Setup "drain" propogation.
 +    // Setup 'drain' propogation.
      httpSocketSetup(socket);
  
-     var errorListener = function(err) {
+     function errorListener(err) {
        debug('HTTP SOCKET ERROR: ' + err.message + '\n' + err.stack);
-       req.emit('error', err);
-       // For Safety. Some additional errors might fire later on
-       // and we need to make sure we don't double-fire the error event.
-       req._hadError = true;
+       if (req) {
+         req.emit('error', err);
+         // For Safety. Some additional errors might fire later on
+         // and we need to make sure we don't double-fire the error event.
+         req._hadError = true;
+       }
        if (parser) {
          parser.finish();
          freeParser(parser, req);
diff --cc lib/module.js
Simple merge
diff --cc src/node.cc
@@@ -1832,13 -1691,13 +1832,17 @@@ void FatalException(TryCatch &try_catch
    Local<Value> error = try_catch.Exception();
    Local<Value> event_argv[2] = { uncaught_exception_symbol_l, error };
  
 -  uncaught_exception_counter++;
 +  TryCatch event_try_catch;
    emit->Call(process, 2, event_argv);
 -  // Decrement so we know if the next exception is a recursion or not
 -  uncaught_exception_counter--;
++
 +  if (event_try_catch.HasCaught()) {
 +    // the uncaught exception event threw, so we must exit.
 +    ReportException(event_try_catch, true);
 +    exit(1);
 +  }
+   // This makes sure uncaught exceptions don't interfere with process.nextTick
+   StartTickSpinner();
  }
  
  
@@@ -2288,7 -2121,7 +2292,6 @@@ void Load(Handle<Object> process_l) 
    // source code.)
  
    // The node.js file returns a function 'f'
--
    atexit(AtExit);
  
    TryCatch try_catch;
diff --cc src/node.js
      };
    };
  
 +  startup.processConfig = function() {
 +    // used for `process.config`, but not a real module
 +    var config = NativeModule._source.config;
 +    delete NativeModule._source.config;
 +
 +    // strip the gyp comment line at the beginning
 +    config = config.split('\n').slice(1).join('\n').replace(/'/g, '"');
 +
 +    process.config = JSON.parse(config, function(key, value) {
 +      if (value === 'true') return true;
 +      if (value === 'false') return false;
 +      return value;
 +    });
 +  }
 +
    startup.processNextTick = function() {
      var nextTickQueue = [];
+     var nextTickIndex = 0;
  
      process._tickCallback = function() {
-       var l = nextTickQueue.length;
-       if (l === 0) return;
-       var q = nextTickQueue;
-       nextTickQueue = [];
-       try {
-         for (var i = 0; i < l; i++) {
-           var tock = q[i];
-           var callback = tock.callback;
-           if (tock.domain) {
-             if (tock.domain._disposed) continue;
-             tock.domain.enter();
-           }
-           callback();
-           if (tock.domain) tock.domain.exit();
+       var nextTickLength = nextTickQueue.length;
+       if (nextTickLength === 0) return;
+       while (nextTickIndex < nextTickLength) {
 -        nextTickQueue[nextTickIndex++]();
++        var tock = nextTickQueue[nextTickIndex++];
++        var callback = tock.callback;
++        if (tock.domain) {
++          if (tock.domain._disposed) continue;
++          tock.domain.enter();
 +        }
-       }
-       catch (e) {
-         if (i + 1 < l) {
-           nextTickQueue = q.slice(i + 1).concat(nextTickQueue);
-         }
-         if (nextTickQueue.length) {
-           process._needTickCallback();
++        callback();
++        if (tock.domain) {
++          tock.domain.exit();
 +        }
-         throw e; // process.nextTick error, or 'error' event on first tick
        }
+       nextTickQueue.splice(0, nextTickIndex);
+       nextTickIndex = 0;
      };
  
      process.nextTick = function(callback) {
@@@ -1,6 -1,6 +1,6 @@@
  before
  
- node.js:*
-         throw e; // process.nextTick error, or 'error' event on first tick
-               ^
+ *test*message*throw_custom_error.js:31
 -throw { name: 'MyCustomError', message: 'This is a custom message' };
++throw ({ name: 'MyCustomError', message: 'This is a custom message' });
+ ^
  MyCustomError: This is a custom message
@@@ -1,6 -1,6 +1,6 @@@
  before
  
- node.js:*
-         throw e; // process.nextTick error, or 'error' event on first tick
-               ^
+ */test/message/throw_non_error.js:31
 -throw { foo: 'bar' };
++throw ({ foo: 'bar' });
+ ^
  [object Object]