From ffc8110659854179cd002d8859668deb59c19a30 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 2 Dec 2011 11:11:25 -0800 Subject: [PATCH 01/17] Workaround: A/V software prevents folder rename --- deps/npm/lib/utils/tar.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/deps/npm/lib/utils/tar.js b/deps/npm/lib/utils/tar.js index 1fe705377..2c2b96f9a 100644 --- a/deps/npm/lib/utils/tar.js +++ b/deps/npm/lib/utils/tar.js @@ -144,7 +144,8 @@ function unpack_ ( tarball, unpackTarget, dMode, fMode, uid, gid, cb ) { rm(unpackTarget, function (er) { if (er) return cb(er) log.verbose(unpackTarget, "rm'ed") - fs.rename(folder, unpackTarget, function (er) { + + moveIntoPlace(folder, unpackTarget, function (er) { if (er) return cb(er) log.verbose([folder, unpackTarget], "renamed") // curse you, nfs! It will lie and tell you that the @@ -161,6 +162,24 @@ function unpack_ ( tarball, unpackTarget, dMode, fMode, uid, gid, cb ) { }) } +// on Windows, A/V software can lock the directory, causing this +// to fail with an EACCES. Try again on failure, for up to 1 second. +// XXX Fix this by not unpacking into a temp directory, instead just +// renaming things on the way out of the tarball. +function moveIntoPlace (folder, unpackTarget, cb) { + var start = Date.now() + fs.rename(folder, unpackTarget, function CB (er) { + if (er + && process.platform === "win32" + && er.code === "EACCES" + && Date.now() - start < 1000) { + return fs.rename(folder, unpackTarget, CB) + } + cb(er) + }) +} + + function gunzTarPerm (tarball, tmp, dMode, fMode, uid, gid, cb) { if (!dMode) dMode = npm.modes.exec if (!fMode) fMode = npm.modes.file From 46b6954acdfaba37cf133bd656ad6a23453e007b Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 2 Dec 2011 17:06:05 -0800 Subject: [PATCH 02/17] Add link to license file on website --- doc/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/index.html b/doc/index.html index 384a8bf87..815c1b32b 100644 --- a/doc/index.html +++ b/doc/index.html @@ -112,6 +112,7 @@ server.listen(1337, "127.0.0.1");
  • node-v0.6.4.msi Windows installer
  • node-v0.6.4.pkg Macintosh installer
  • Documentation +
  • License
  • Other release files (like .exe and .pdb) From 1cf26e2bf1d305c1e444f50ed0f4ed08b8df7106 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 3 Dec 2011 23:30:56 -0800 Subject: [PATCH 03/17] Upgrade V8 to 3.6.6.11 --- deps/v8/src/debug.cc | 38 ----------------------------- deps/v8/src/log.h | 6 +++++ deps/v8/src/version.cc | 2 +- deps/v8/test/mjsunit/mjsunit.status | 4 +++ 4 files changed, 11 insertions(+), 39 deletions(-) diff --git a/deps/v8/src/debug.cc b/deps/v8/src/debug.cc index a229d39c3..20cd80274 100644 --- a/deps/v8/src/debug.cc +++ b/deps/v8/src/debug.cc @@ -1731,44 +1731,6 @@ void Debug::PrepareForBreakPoints() { // functions as debugging does not work with optimized code. if (!has_break_points_) { Deoptimizer::DeoptimizeAll(); - - AssertNoAllocation no_allocation; - Builtins* builtins = isolate_->builtins(); - Code* lazy_compile = builtins->builtin(Builtins::kLazyCompile); - - // Find all non-optimized code functions with activation frames on - // the stack. - List active_functions(100); - for (JavaScriptFrameIterator it(isolate_); !it.done(); it.Advance()) { - JavaScriptFrame* frame = it.frame(); - if (frame->function()->IsJSFunction()) { - JSFunction* function = JSFunction::cast(frame->function()); - if (function->code()->kind() == Code::FUNCTION) - active_functions.Add(function); - } - } - active_functions.Sort(); - - // Scan the heap for all non-optimized functions which has no - // debug break slots. - HeapIterator iterator; - HeapObject* obj = NULL; - while (((obj = iterator.next()) != NULL)) { - if (obj->IsJSFunction()) { - JSFunction* function = JSFunction::cast(obj); - if (function->shared()->allows_lazy_compilation() && - function->shared()->script()->IsScript() && - function->code()->kind() == Code::FUNCTION && - !function->code()->has_debug_break_slots()) { - bool has_activation = - SortedListBSearch(active_functions, function) != -1; - if (!has_activation) { - function->set_code(lazy_compile); - function->shared()->set_code(lazy_compile); - } - } - } - } } } diff --git a/deps/v8/src/log.h b/deps/v8/src/log.h index fe19810a2..50358ce56 100644 --- a/deps/v8/src/log.h +++ b/deps/v8/src/log.h @@ -294,7 +294,13 @@ class Logger { INLINE(static LogEventsAndTags ToNativeByScript(LogEventsAndTags, Script*)); // Profiler's sampling interval (in milliseconds). +#if defined(ANDROID) + // Phones and tablets have processors that are much slower than desktop + // and laptop computers for which current heuristics are tuned. + static const int kSamplingIntervalMs = 5; +#else static const int kSamplingIntervalMs = 1; +#endif // Callback from Log, stops profiling in case of insufficient resources. void LogFailure(); diff --git a/deps/v8/src/version.cc b/deps/v8/src/version.cc index 2865502c1..7f916e17c 100644 --- a/deps/v8/src/version.cc +++ b/deps/v8/src/version.cc @@ -35,7 +35,7 @@ #define MAJOR_VERSION 3 #define MINOR_VERSION 6 #define BUILD_NUMBER 6 -#define PATCH_LEVEL 8 +#define PATCH_LEVEL 11 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) #define IS_CANDIDATE_VERSION 0 diff --git a/deps/v8/test/mjsunit/mjsunit.status b/deps/v8/test/mjsunit/mjsunit.status index 027da584b..bae09b4e3 100644 --- a/deps/v8/test/mjsunit/mjsunit.status +++ b/deps/v8/test/mjsunit/mjsunit.status @@ -34,6 +34,10 @@ bugs: FAIL # Fails. regress/regress-1119: FAIL +############################################################################# +# Fails due to r10102 which reverts precise stepping on the 3.6 branch. +debug-step-2: FAIL + ############################################################################## # Too slow in debug mode with --stress-opt compiler/regress-stacktrace-methods: PASS, SKIP if $mode == debug From 60e26668b3c73b9163d9fb1ae6a7951c6acbc889 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 4 Dec 2011 00:09:02 -0800 Subject: [PATCH 04/17] Remove superfluous 'new' --- lib/child_process.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/child_process.js b/lib/child_process.js index 1eba363fd..dcff85ab3 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -33,7 +33,7 @@ var Pipe; function createPipe(ipc) { // Lazy load if (!Pipe) { - Pipe = new process.binding('pipe_wrap').Pipe; + Pipe = process.binding('pipe_wrap').Pipe; } return new Pipe(ipc); From 6cc94db653a2739ab28e33b2d6a63c51bd986a9f Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 3 Dec 2011 23:18:35 -0800 Subject: [PATCH 05/17] Bump version to v0.6.5 --- ChangeLog | 7 +++++++ doc/index.html | 16 ++++++++-------- doc/template.html | 4 ++-- src/node_version.h | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 06a9a4ff2..9a544f0ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011.12.04, Version 0.6.5 (stable) + +* npm workaround Windows antivirus software (isaacs) + +* Upgrade V8 to 3.6.6.11 + + 2011.12.02, Version 0.6.4 (stable), 9170077f13e5e5475b23d1d3c2e7f69bfe139727 * doc improvements (Kyle Young, Tim Oxley, Roman Shtylman, Mathias Bynens) diff --git a/doc/index.html b/doc/index.html index 815c1b32b..d0829b83a 100644 --- a/doc/index.html +++ b/doc/index.html @@ -26,7 +26,7 @@
  • Download
  • ChangeLog
  • About
  • -
  • v0.6.4 docs
  • +
  • v0.6.5 docs

  • Wiki
  • Blog
  • @@ -105,15 +105,15 @@ server.listen(1337, "127.0.0.1");

    Download

    -

    2011.12.02 v0.6.4 +

    2011.12.04 v0.6.5

    diff --git a/doc/template.html b/doc/template.html index c367bb48d..fc3524d59 100644 --- a/doc/template.html +++ b/doc/template.html @@ -2,7 +2,7 @@ - {{section}}Node.js v0.6.4 Manual & Documentation + {{section}}Node.js v0.6.5 Manual & Documentation @@ -10,7 +10,7 @@
    -

    Node.js v0.6.4 Manual & Documentation

    +

    Node.js v0.6.5 Manual & Documentation

    diff --git a/src/node_version.h b/src/node_version.h index d424b4e9d..9c9d1c814 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -29,7 +29,7 @@ #define NODE_MAJOR_VERSION 0 #define NODE_MINOR_VERSION 6 #define NODE_PATCH_VERSION 5 -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n) From c50b0c9237efb951f432b5792e9aec3ff1d9475f Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 4 Dec 2011 00:59:16 -0800 Subject: [PATCH 06/17] Now working on Node v0.6.6 --- src/node_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_version.h b/src/node_version.h index 9c9d1c814..42099bcb3 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -28,8 +28,8 @@ #define NODE_MAJOR_VERSION 0 #define NODE_MINOR_VERSION 6 -#define NODE_PATCH_VERSION 5 -#define NODE_VERSION_IS_RELEASE 1 +#define NODE_PATCH_VERSION 6 +#define NODE_VERSION_IS_RELEASE 0 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n) From a0fdd5f3f6539684ec1dd5bf7f2d2367bc7d4adb Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 4 Dec 2011 13:22:21 +0100 Subject: [PATCH 07/17] uv: upgrade to 34e95d1 --- deps/uv/src/unix/core.c | 10 +++++++++- deps/uv/src/unix/error.c | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index 7978e1bb2..911503605 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -169,7 +169,15 @@ uv_loop_t* uv_loop_new(void) { void uv_loop_delete(uv_loop_t* loop) { uv_ares_destroy(loop, loop->channel); ev_loop_destroy(loop->ev); - free(loop); + +#ifndef NDEBUG + memset(loop, 0, sizeof *loop); +#endif + + if (loop == default_loop_ptr) + default_loop_ptr = NULL; + else + free(loop); } diff --git a/deps/uv/src/unix/error.c b/deps/uv/src/unix/error.c index 5f43709d7..e904d3903 100644 --- a/deps/uv/src/unix/error.c +++ b/deps/uv/src/unix/error.c @@ -82,6 +82,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) { case EHOSTUNREACH: return UV_EHOSTUNREACH; case EAI_NONAME: return UV_ENOENT; case ESRCH: return UV_ESRCH; + case ETIMEDOUT: return UV_ETIMEDOUT; default: return UV_UNKNOWN; } From aeb124f7f3625bff31d88dc3e42ad621028febf6 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 5 Dec 2011 06:37:18 +0100 Subject: [PATCH 08/17] test: create test file in temp dir --- test/simple/test-fs-long-path.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/simple/test-fs-long-path.js b/test/simple/test-fs-long-path.js index dfd68802a..2ae80d0ed 100644 --- a/test/simple/test-fs-long-path.js +++ b/test/simple/test-fs-long-path.js @@ -19,6 +19,7 @@ // 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 fs = require('fs'); var path = require('path'); var assert = require('assert'); @@ -26,9 +27,8 @@ var assert = require('assert'); var successes = 0; // make a path that will be at least 260 chars long. -var cwd = process.cwd(); -var fileNameLen = Math.max(260 - cwd.length - 1, 1); -var fileName = new Array(fileNameLen + 1).join('x'); +var fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1); +var fileName = path.join(common.tmpDir, new Array(fileNameLen + 1).join('x')); var fullPath = path.resolve(fileName); console.log({ filenameLength: fileName.length, From fdf180f9ceefe9598f0a43e01dab825e19250e40 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 5 Dec 2011 08:42:11 +0100 Subject: [PATCH 09/17] cli: fix output of --help --- src/node.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/node.cc b/src/node.cc index 5402069ae..d0c540ff9 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2217,8 +2217,12 @@ static void PrintHelp() { " --vars print various compiled-in variables\n" " --max-stack-size=val set max v8 stack size (bytes)\n" "\n" - "Enviromental variables:\n" + "Environment variables:\n" +#ifdef _WIN32 + "NODE_PATH ';'-separated list of directories\n" +#else "NODE_PATH ':'-separated list of directories\n" +#endif " prefixed to the module search path.\n" "NODE_MODULE_CONTEXTS Set to 1 to load modules in their own\n" " global contexts.\n" From 1a89c8d061b36e01cd0f7f12704dc9688d351df7 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 5 Dec 2011 11:17:57 -0800 Subject: [PATCH 10/17] Add analytics tracking to docs --- doc/template.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/template.html b/doc/template.html index fc3524d59..377cae8b3 100644 --- a/doc/template.html +++ b/doc/template.html @@ -21,5 +21,16 @@ + + + From 36815e41796475b1f72aacb3acb406ff07ef90c7 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 5 Dec 2011 22:42:05 +0100 Subject: [PATCH 11/17] process: fix stack overflow when recursively calling process.exit() --- src/node.js | 7 ++++++- test/simple/test-process-exit.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 test/simple/test-process-exit.js diff --git a/src/node.js b/src/node.js index 53e0c489c..5e7ae1206 100644 --- a/src/node.js +++ b/src/node.js @@ -336,8 +336,13 @@ }; startup.processKillAndExit = function() { + var exiting = false; + process.exit = function(code) { - process.emit('exit', code || 0); + if (!exiting) { + exiting = true; + process.emit('exit', code || 0); + } process.reallyExit(code || 0); }; diff --git a/test/simple/test-process-exit.js b/test/simple/test-process-exit.js new file mode 100644 index 000000000..59e9cbd15 --- /dev/null +++ b/test/simple/test-process-exit.js @@ -0,0 +1,32 @@ +// 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 assert = require('assert'); + +// recursively calling .exit() should not overflow the call stack +var nexits = 0; + +process.on('exit', function() { + assert.equal(nexits++, 0); + process.exit(); +}); + +process.exit(); From db273818f6cafeab443746f128ef7522c0dedb90 Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 1 Dec 2011 18:19:17 -0800 Subject: [PATCH 12/17] s/NPM/npm/ http://npmjs.org/doc/faq.html#If-npm-is-an-acronym-why-is-it-never-capitalized --- LICENSE | 6 +++--- doc/v0.4_announcement.html | 2 +- lib/net.js | 2 +- tools/osx-pkg.pmdoc/index.xml | 4 ++-- wscript | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/LICENSE b/LICENSE index 204ff4b93..c655cbaf9 100644 --- a/LICENSE +++ b/LICENSE @@ -79,8 +79,8 @@ The externally maintained libraries used by Node are: licensed under a permissive free software license. See deps/zlib/LICENSE. - - deps/npm NPM is a package manager program copyright 2009, 2010, 2011 - Isaac Z. Schlueter and licensed under MIT. NPM includes several + - deps/npm npm is a package manager program copyright 2009, 2010, 2011 + Isaac Z. Schlueter and licensed under MIT. npm includes several subpackages MIT or Apache licenses, see deps/npm/LICENSE for more - information. NPM is included in the Node .msi and .pkg distributions + information. npm is included in the Node .msi and .pkg distributions but not in the Node binary itself. diff --git a/doc/v0.4_announcement.html b/doc/v0.4_announcement.html index 8ecda802c..7d68376bc 100644 --- a/doc/v0.4_announcement.html +++ b/doc/v0.4_announcement.html @@ -43,7 +43,7 @@
  • With a good amount of experience now, some modifications to the module loading system were made to better support package managers. - In particular, NPM was forced to resort to deep symlinks and "shim" + In particular, npm was forced to resort to deep symlinks and "shim" modules to work around missing features in require(). The main changes are:
      diff --git a/lib/net.js b/lib/net.js index b06a78d25..13b33a45b 100644 --- a/lib/net.js +++ b/lib/net.js @@ -101,7 +101,7 @@ function Socket(options) { if (typeof options == 'number') { // Legacy interface. - // Must support legacy interface. NPM depends on it. + // Must support legacy interface. Old versions of npm depend on it. // https://github.com/isaacs/npm/blob/c7824f412f0cb59d6f55cf0bc220253c39e6029f/lib/utils/output.js#L110 var fd = options; diff --git a/tools/osx-pkg.pmdoc/index.xml b/tools/osx-pkg.pmdoc/index.xml index d805747fc..4ba2725c1 100644 --- a/tools/osx-pkg.pmdoc/index.xml +++ b/tools/osx-pkg.pmdoc/index.xml @@ -12,8 +12,8 @@ \ /usr/local/bin/node\ \ -NPM was installed at\ +npm was installed at\ \ /usr/local/bin/npm\ \ -Make sure that /usr/local/bin is in your $PATH.}]]>01local.xml02npm.xmlproperties.titleproperties.userDomainproperties.anywhereDomainproperties.systemDomain \ No newline at end of file +Make sure that /usr/local/bin is in your $PATH.}]]>01local.xml02npm.xmlproperties.titleproperties.userDomainproperties.anywhereDomainproperties.systemDomain diff --git a/wscript b/wscript index 52c5edcee..0d922e663 100644 --- a/wscript +++ b/wscript @@ -980,7 +980,7 @@ def install_npm(bld): start_dir = bld.path.find_dir('deps/npm') # The chmod=-1 is a Node hack. We changed WAF so that when chmod was set to # -1 that the same permission in this tree are used. Necessary to get - # npm-cli.js to be executable without having to list every file in NPM. + # npm-cli.js to be executable without having to list every file in npm. bld.install_files('${LIBDIR}/node_modules/npm', start_dir.ant_glob('**/*'), cwd=start_dir, From 6f86b9cb70f4b4d9b214ef3533efbf389fa43824 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 5 Dec 2011 16:25:20 -0800 Subject: [PATCH 13/17] Disable test-setproctitle on darwin --- test/simple/test-setproctitle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/simple/test-setproctitle.js b/test/simple/test-setproctitle.js index 4276d2d36..0bf6fd35c 100644 --- a/test/simple/test-setproctitle.js +++ b/test/simple/test-setproctitle.js @@ -22,7 +22,7 @@ // Original test written by Jakub Lekstan // FIXME add sunos support -if ('linux darwin freebsd'.indexOf(process.platform) === -1) { +if ('linux freebsd'.indexOf(process.platform) === -1) { console.error("Skipping test, platform not supported."); process.exit(); } From cf20b6bf65bd037193d6e8b1b671c4659897861f Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 5 Dec 2011 15:36:45 -0800 Subject: [PATCH 14/17] Fix #2257 pause/resume semantics for stdin This makes it so that the stdin TTY-wrap stream gets ref'ed on .resume() and unref'ed on .pause() The semantics of the names "pause" and "resume" are a bit weird, but the important thing is that this corrects an API change from 0.4 -> 0.6 which made it impossible to read from stdin multiple times, without knowing when it might end up being closed. If no one has it open, this lets the process die naturally. LGTM'd by @ry --- lib/net.js | 4 ++- lib/tty.js | 11 ++++++++ src/handle_wrap.cc | 30 ++++++++++++++++----- src/handle_wrap.h | 1 + src/pipe_wrap.cc | 1 + src/tty_wrap.cc | 1 + test/simple/test-stdin-pause-resume.js | 37 ++++++++++++++++++++++++++ 7 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 test/simple/test-stdin-pause-resume.js diff --git a/lib/net.js b/lib/net.js index 13b33a45b..aa6e043ea 100644 --- a/lib/net.js +++ b/lib/net.js @@ -194,7 +194,9 @@ Object.defineProperty(Socket.prototype, 'bufferSize', { Socket.prototype.pause = function() { - this._handle.readStop(); + if (this._handle) { + this._handle.readStop(); + } }; diff --git a/lib/tty.js b/lib/tty.js index 78971dda3..32ba512d5 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -83,8 +83,19 @@ function ReadStream(fd) { this.on('newListener', onNewListener); } inherits(ReadStream, net.Socket); + exports.ReadStream = ReadStream; +ReadStream.prototype.pause = function() { + this._handle.unref(); + return net.Socket.prototype.pause.call(this); +}; + +ReadStream.prototype.resume = function() { + this._handle.ref(); + return net.Socket.prototype.resume.call(this); +}; + ReadStream.prototype.isTTY = true; diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index 6e0764389..5b6594a3a 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -64,8 +64,10 @@ Handle HandleWrap::Unref(const Arguments& args) { UNWRAP - // Calling this function twice should never happen. - assert(wrap->unref == false); + // Calling unnecessarily is a no-op + if (wrap->unref) { + return v8::Undefined(); + } wrap->unref = true; uv_unref(uv_default_loop()); @@ -74,6 +76,24 @@ Handle HandleWrap::Unref(const Arguments& args) { } +// Adds a reference to keep uv alive because of this thing. +Handle HandleWrap::Ref(const Arguments& args) { + HandleScope scope; + + UNWRAP + + // Calling multiple times is a no-op + if (!wrap->unref) { + return v8::Undefined(); + } + + wrap->unref = false; + uv_ref(uv_default_loop()); + + return v8::Undefined(); +} + + Handle HandleWrap::Close(const Arguments& args) { HandleScope scope; @@ -82,10 +102,8 @@ Handle HandleWrap::Close(const Arguments& args) { assert(!wrap->object_.IsEmpty()); uv_close(wrap->handle__, OnClose); - if (wrap->unref) { - uv_ref(uv_default_loop()); - wrap->unref = false; - } + + HandleWrap::Ref(args); wrap->StateChange(); diff --git a/src/handle_wrap.h b/src/handle_wrap.h index fc6d623ac..b9cf31e8e 100644 --- a/src/handle_wrap.h +++ b/src/handle_wrap.h @@ -49,6 +49,7 @@ class HandleWrap { static void Initialize(v8::Handle target); static v8::Handle Close(const v8::Arguments& args); static v8::Handle Unref(const v8::Arguments& args); + static v8::Handle Ref(const v8::Arguments& args); protected: HandleWrap(v8::Handle object, uv_handle_t* handle); diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index a2a4203a8..1870837bc 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -85,6 +85,7 @@ void PipeWrap::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(t, "close", HandleWrap::Close); NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref); + NODE_SET_PROTOTYPE_METHOD(t, "ref", HandleWrap::Ref); NODE_SET_PROTOTYPE_METHOD(t, "readStart", StreamWrap::ReadStart); NODE_SET_PROTOTYPE_METHOD(t, "readStop", StreamWrap::ReadStop); diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index b46e6c4e1..486c2a70b 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -69,6 +69,7 @@ class TTYWrap : StreamWrap { NODE_SET_PROTOTYPE_METHOD(t, "close", HandleWrap::Close); NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref); + NODE_SET_PROTOTYPE_METHOD(t, "ref", HandleWrap::Ref); NODE_SET_PROTOTYPE_METHOD(t, "readStart", StreamWrap::ReadStart); NODE_SET_PROTOTYPE_METHOD(t, "readStop", StreamWrap::ReadStop); diff --git a/test/simple/test-stdin-pause-resume.js b/test/simple/test-stdin-pause-resume.js new file mode 100644 index 000000000..cfa44bae2 --- /dev/null +++ b/test/simple/test-stdin-pause-resume.js @@ -0,0 +1,37 @@ +// 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. + +console.error("before opening stdin"); +process.stdin.resume(); +console.error("stdin opened"); +setTimeout(function() { + console.error("pausing stdin"); + process.stdin.pause(); + setTimeout(function() { + console.error("opening again"); + process.stdin.resume(); + setTimeout(function() { + console.error("pausing again"); + process.stdin.pause(); + console.error("should exit now"); + }, 1); + }, 1); +}, 1); From 9023b0b3a28824800e8a6a1bf921f47741691c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Sun, 4 Dec 2011 01:23:59 +0100 Subject: [PATCH 15/17] test: add `.travis.yml` for testing on Travis CI As discussed with @isaacs, build reports will be sent to #libuv IRC channel. E-mail notifications are turned off so that Travis doesn't bother committers about failures in forks. --- .travis.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..595409cef --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: node_js + +before_script: + - "./configure" + - "make" + +script: + - "make test" + +notifications: + email: false + irc: + - "irc.freenode.net#libuv" + From 89e894b17abcf1619346c6e74b46e20eb2c7f732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Sun, 4 Dec 2011 01:58:49 +0100 Subject: [PATCH 16/17] doc: add Travis CI build status image --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d58837ed1..c16758957 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Evented I/O for V8 javascript. +Evented I/O for V8 javascript. [![Build Status](https://secure.travis-ci.org/joyent/node.png)](http://travis-ci.org/joyent/node) === ### To build: From 580e67015c464e8d2746fed9d1f2dcd26138aaef Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 5 Dec 2011 17:52:22 -0800 Subject: [PATCH 17/17] Apply #2257 fix for Pipe streams as well as TTYs --- lib/net.js | 10 ++++++++++ test/simple/test-stdin-child-proc.js | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/simple/test-stdin-child-proc.js diff --git a/lib/net.js b/lib/net.js index aa6e043ea..19858e80d 100644 --- a/lib/net.js +++ b/lib/net.js @@ -196,6 +196,11 @@ Object.defineProperty(Socket.prototype, 'bufferSize', { Socket.prototype.pause = function() { if (this._handle) { this._handle.readStop(); + + // this adds an undesireable boundary crossing for pipe streams. + // the .unref() method is omitted on TCP streams, because it is + // unnecessary. + if (this._handle.unref) this._handle.unref(); } }; @@ -203,6 +208,11 @@ Socket.prototype.pause = function() { Socket.prototype.resume = function() { if (this._handle) { this._handle.readStart(); + + // this adds an undesireable boundary crossing for pipe streams. + // the .ref() method is omitted on TCP streams, because it is + // unnecessary. + if (this._handle.ref) this._handle.ref(); } }; diff --git a/test/simple/test-stdin-child-proc.js b/test/simple/test-stdin-child-proc.js new file mode 100644 index 000000000..6c499995d --- /dev/null +++ b/test/simple/test-stdin-child-proc.js @@ -0,0 +1,27 @@ +// 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. + +// This tests that pausing and resuming stdin does not hang and timeout +// when done in a child process. See test/simple/test-stdin-pause-resume.js +var child_process = require('child_process'); +var path = require('path'); +child_process.spawn(process.execPath, + [ path.resolve(__dirname, 'test-stdin-pause-resume.js') ]);