Showing with 70 additions and 20 deletions.
  1. +7 −1 deps/uv/src/unix/threadpool.c
  2. +3 −0 deps/uv/test/runner-win.c
  3. +2 −0 deps/uv/test/test-list.h
  4. +1 −0 deps/uv/uv.gyp
  5. +13 −5 lib/module.js
  6. +1 −5 lib/repl.js
  7. +14 −8 lib/tls.js
  8. +1 −1 test/simple/test-stdout-to-file.js
  9. +28 −0 test/simple/test-tls-handshake-nohang.js
@@ -31,6 +31,7 @@ static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_t threads[4];
static ngx_queue_t exit_message;
static ngx_queue_t wq = { &wq, &wq };
static volatile int initialized;


static void* worker(void* arg) {
@@ -89,6 +90,8 @@ static void init_once(void) {
for (i = 0; i < ARRAY_SIZE(threads); i++)
if (pthread_create(threads + i, NULL, worker, NULL))
abort();

initialized = 1;
}


@@ -97,11 +100,14 @@ static void cleanup(void) {
unsigned int i;
int err;

if (initialized == 0)
return;

post(&exit_message);

for (i = 0; i < ARRAY_SIZE(threads); i++) {
err = pthread_join(threads[i], NULL);
assert(err == 0 || err == EINVAL || err == ESRCH);
assert(err == 0 || err == ESRCH);
(void) err; /* Silence compiler warning in release builds. */
}
}
@@ -24,6 +24,7 @@
#include <malloc.h>
#include <stdio.h>
#include <process.h>
#include <crtdbg.h>

#include "task.h"
#include "runner.h"
@@ -43,6 +44,8 @@ void platform_init(int argc, char **argv) {
/* Disable the "application crashed" popup. */
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);

_setmode(0, _O_BINARY);
_setmode(1, _O_BINARY);
@@ -27,6 +27,7 @@ TEST_DECLARE (condvar_2)
TEST_DECLARE (condvar_3)
TEST_DECLARE (condvar_4)
TEST_DECLARE (condvar_5)
TEST_DECLARE (consumer_producer)
TEST_DECLARE (semaphore_1)
TEST_DECLARE (semaphore_2)
TEST_DECLARE (semaphore_3)
@@ -218,6 +219,7 @@ TASK_LIST_START
TEST_ENTRY (condvar_3)
TEST_ENTRY (condvar_4)
TEST_ENTRY (condvar_5)
TEST_ENTRY (consumer_producer)
TEST_ENTRY (semaphore_1)
TEST_ENTRY (semaphore_2)
TEST_ENTRY (semaphore_3)
@@ -306,6 +306,7 @@
'test/test-signal.c',
'test/test-thread.c',
'test/test-condvar.c',
'test/test-condvar-consumer-producer.c',
'test/test-timer-again.c',
'test/test-timer.c',
'test/test-tty.c',
@@ -497,16 +497,24 @@ Module.runMain = function() {
Module._load(process.argv[1], null, true);
};

Module._initPaths = function() {
Module._initPaths = function () {
var isWindows = process.platform === 'win32';

if (!isWindows) {
var homeDir = process.env.HOME;
} else {
var homeDir = process.env.USERPROFILE;
}

var paths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')];

if (process.env['HOME']) {
paths.unshift(path.resolve(process.env['HOME'], '.node_libraries'));
paths.unshift(path.resolve(process.env['HOME'], '.node_modules'));
if (homeDir) {
paths.unshift(path.resolve(homeDir, '.node_libraries'));
paths.unshift(path.resolve(homeDir, '.node_modules'));
}

if (process.env['NODE_PATH']) {
var splitter = process.platform === 'win32' ? ';' : ':';
var splitter = isWindows ? ';' : ':';
paths = process.env['NODE_PATH'].split(splitter).concat(paths);
}

@@ -454,11 +454,7 @@ REPLServer.prototype.complete = function(line, callback) {
completionGroupsLoaded();
} else if (match = line.match(requireRE)) {
// require('...<Tab>')
//TODO: suggest require.exts be exposed to be introspec registered
//extensions?
//TODO: suggest include the '.' in exts in internal repr: parity with
//`path.extname`.
var exts = ['.js', '.node'];
var exts = Object.keys(require.extensions);
var indexRe = new RegExp('^index(' + exts.map(regexpEscape).join('|') +
')$');

@@ -700,15 +700,21 @@ EncryptedStream.prototype._pusher = function(pool, offset, length) {
function onhandshakestart() {
debug('onhandshakestart');

var self = this, ssl = this.ssl;
var self = this;
var ssl = self.ssl;
var now = Date.now();

assert(now >= ssl.lastHandshakeTime);

if (ssl.timer === null) {
ssl.timer = setTimeout(function timeout() {
ssl.handshakes = 0;
ssl.timer = null;
}, exports.CLIENT_RENEG_WINDOW * 1000);
if ((now - ssl.lastHandshakeTime) >= exports.CLIENT_RENEG_WINDOW * 1000) {
ssl.handshakes = 0;
}
else if (++ssl.handshakes > exports.CLIENT_RENEG_LIMIT) {

var first = (ssl.lastHandshakeTime === 0);
ssl.lastHandshakeTime = now;
if (first) return;

if (++ssl.handshakes > exports.CLIENT_RENEG_LIMIT) {
// Defer the error event to the next tick. We're being called from OpenSSL's
// state machine and OpenSSL is not re-entrant. We cannot allow the user's
// callback to destroy the connection right now, it would crash and burn.
@@ -810,8 +816,8 @@ function SecurePair(credentials, isServer, requestCert, rejectUnauthorized,
this.ssl.onhandshakedone = onhandshakedone.bind(this);
this.ssl.onclienthello = onclienthello.bind(this);
this.ssl.onnewsession = onnewsession.bind(this);
this.ssl.lastHandshakeTime = 0;
this.ssl.handshakes = 0;
this.ssl.timer = null;
}

if (process.features.tls_sni) {
@@ -30,7 +30,7 @@ var fs = require('fs');

var scriptString = path.join(common.fixturesDir, 'print-chars.js');
var scriptBuffer = path.join(common.fixturesDir, 'print-chars-from-buffer.js');
var tmpFile = path.join(common.fixturesDir, 'stdout.txt');
var tmpFile = path.join(common.tmpDir, 'stdout.txt');

function test(size, useBuffer, cb) {
var cmd = '"' + process.argv[0] + '"' +
@@ -0,0 +1,28 @@
// 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 tls = require('tls');

// neither should hang
tls.createSecurePair(null, false, false, false);
tls.createSecurePair(null, true, false, false);