Browse Source

Merge branch 'v0.6.11-release' into v0.6

v0.8.7-release
isaacs 13 years ago
parent
commit
dfed2cef75
  1. 5
      AUTHORS
  2. 42
      ChangeLog
  3. 4
      Makefile
  4. 2
      deps/uv/include/uv-private/uv-win.h
  5. 4
      deps/uv/src/unix/tty.c
  6. 8
      deps/uv/src/win/error.c
  7. 83
      deps/uv/src/win/fs.c
  8. 2
      deps/uv/test/test-fs.c
  9. 2
      doc/about/index.html
  10. 2
      doc/community/index.html
  11. 18
      doc/index.html
  12. 2
      doc/logos/index.html
  13. 6
      doc/template.html
  14. 24
      lib/net.js
  15. 2
      src/node_version.h
  16. 77
      test/simple/test-cluster-bind-twice-v1.js
  17. 115
      test/simple/test-cluster-bind-twice-v2.js

5
AUTHORS

@ -261,3 +261,8 @@ Brandon Benvie <brandon@bbenvie.com>
Nicolas LaCasse <nlacasse@borderstylo.com>
Dan VerWeire <dverweire@gmail.com>
Matthew Fitzsimmons <matt@joyent.com>
Paddy Byers <paddy.byers@gmail.com>
Philip Tellis <philip.tellis@gmail.com>
Christopher Jeffrey <chjjeffrey@gmail.com>
Seth Fitzsimmons <seth@mojodna.net>
Einar Otto Stangvik <einaros@gmail.com>

42
ChangeLog

@ -1,4 +1,44 @@
2012.02.02, Version 0.6.10 (stable)
2012.02.17 Version 0.6.11 (stable)
* http: allow multiple WebSocket RFC6455 headers (Einar Otto Stangvik)
* http: allow multiple WWW-Authenticate headers (Ben Noordhuis)
* windows: support unicode argv and environment variables (Bert Belder)
* tls: mitigate session renegotiation attacks (Ben Noordhuis)
* tcp, pipe: don't assert on uv_accept() errors (Ben Noordhuis)
* tls: Allow establishing secure connection on the existing socket (koichik)
* dgram: handle close of dgram socket before DNS lookup completes (Seth Fitzsimmons)
* windows: Support half-duplex pipes (Igor Zinkovsky)
* build: disable omit-frame-pointer on solaris systems (Dave Pacheco)
* debugger: fix --debug-brk (Ben Noordhuis)
* net: fix large file downloads failing (koichik)
* fs: fix ReadStream failure to read from existing fd (Christopher Jeffrey)
* net: destroy socket on DNS error (Stefan Rusu)
* dtrace: add missing translator (Dave Pacheco)
* unix: don't flush tty on switch to raw mode (Ben Noordhuis)
* windows: reset brightness when reverting to default text color (Bert Belder)
* npm: update to 1.1.1
- Update which, fstream, mkdirp, request, and rimraf
- Fix #2123 Set path properly for lifecycle scripts on windows
- Mark the root as seen, so we don't recurse into it. Fixes #1838. (Martin Cooper)
2012.02.02, Version 0.6.10 (stable), 051908e023f87894fa68f5b64d0b99a19a7db01e
* Update V8 to 3.6.6.20

4
Makefile

@ -173,8 +173,8 @@ pkg: $(PKG)
$(PKG):
-rm -rf $(PKGDIR)
$(WAF) configure --prefix=/usr/local --without-snapshot
DESTDIR=$(PKGDIR) $(WAF) install
$(WAF) configure --prefix=/usr/local --without-snapshot --dest-cpu=ia32
CFLAGS=-m32 DESTDIR=$(PKGDIR) $(WAF) install
$(packagemaker) \
--id "org.nodejs.NodeJS-$(VERSION)" \
--doc tools/osx-pkg.pmdoc \

2
deps/uv/include/uv-private/uv-win.h

@ -388,7 +388,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
#define UV_FS_PRIVATE_FIELDS \
wchar_t* pathw; \
int flags; \
int last_error; \
DWORD sys_errno_; \
struct _stati64 stat; \
void* arg0; \
union { \

4
deps/uv/src/unix/tty.c

@ -76,8 +76,8 @@ int uv_tty_set_mode(uv_tty_t* tty, int mode) {
raw.c_cc[VMIN] = 1;
raw.c_cc[VTIME] = 0;
/* Put terminal in raw mode after flushing */
if (tcsetattr(fd, TCSAFLUSH, &raw)) {
/* Put terminal in raw mode after draining */
if (tcsetattr(fd, TCSADRAIN, &raw)) {
goto fatal;
}

8
deps/uv/src/win/error.c

@ -84,6 +84,8 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case WSAECONNREFUSED: return UV_ECONNREFUSED;
case ERROR_NETNAME_DELETED: return UV_ECONNRESET;
case WSAECONNRESET: return UV_ECONNRESET;
case ERROR_ALREADY_EXISTS: return UV_EEXIST;
case ERROR_FILE_EXISTS: return UV_EEXIST;
case WSAEFAULT: return UV_EFAULT;
case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH;
case WSAEHOSTUNREACH: return UV_EHOSTUNREACH;
@ -93,6 +95,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case ERROR_TOO_MANY_OPEN_FILES: return UV_EMFILE;
case WSAEMFILE: return UV_EMFILE;
case WSAEMSGSIZE: return UV_EMSGSIZE;
case ERROR_FILENAME_EXCED_RANGE: return UV_ENAMETOOLONG;
case ERROR_NETWORK_UNREACHABLE: return UV_ENETUNREACH;
case WSAENETUNREACH: return UV_ENETUNREACH;
case WSAENOBUFS: return UV_ENOBUFS;
@ -105,9 +108,12 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case ERROR_INVALID_PARAMETER: return UV_EINVAL;
case ERROR_NO_UNICODE_TRANSLATION: return UV_ECHARSET;
case ERROR_BROKEN_PIPE: return UV_EOF;
case ERROR_BAD_PIPE: return UV_EPIPE;
case ERROR_NO_DATA: return UV_EPIPE;
case ERROR_PIPE_NOT_CONNECTED: return UV_EPIPE;
case ERROR_PIPE_BUSY: return UV_EBUSY;
case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT;
case ERROR_ALREADY_EXISTS: return UV_EEXIST;
case WSAETIMEDOUT: return UV_ETIMEDOUT;
case WSAHOST_NOT_FOUND: return UV_ENOENT;
default: return UV_UNKNOWN;
}

83
deps/uv/src/win/fs.c

@ -38,7 +38,6 @@
#define UV_FS_FREE_ARG1 0x0004
#define UV_FS_FREE_PTR 0x0008
#define UV_FS_CLEANEDUP 0x0010
#define UV_FS_LAST_ERROR_SET 0x0020
#define UTF8_TO_UTF16(s, t) \
@ -88,33 +87,30 @@
uv_ref((loop));
#define SET_UV_LAST_ERROR_FROM_REQ(req) \
if (req->flags & UV_FS_LAST_ERROR_SET) { \
uv__set_sys_error(req->loop, req->last_error); \
} else if (req->result == -1) { \
uv__set_error(req->loop, (uv_err_code)req->errorno, req->last_error); \
}
#define SET_REQ_LAST_ERROR(req, error) \
req->last_error = error; \
req->flags |= UV_FS_LAST_ERROR_SET;
uv__set_error(req->loop, req->errorno, req->sys_errno_);
#define SET_REQ_RESULT(req, result_value) \
req->result = (result_value); \
if (req->result == -1) { \
req->last_error = _doserrno; \
req->errorno = uv_translate_sys_error(req->last_error); \
req->sys_errno_ = _doserrno; \
req->errorno = uv_translate_sys_error(req->sys_errno_); \
}
#define SET_REQ_RESULT_WIN32_ERROR(req, sys_errno) \
#define SET_REQ_WIN32_ERROR(req, sys_errno) \
req->result = -1; \
req->sys_errno_ = (sys_errno); \
req->errorno = uv_translate_sys_error(req->sys_errno_);
#define SET_REQ_UV_ERROR(req, uv_errno, sys_errno) \
req->result = -1; \
req->errorno = uv_translate_sys_error(sys_errno); \
SET_REQ_LAST_ERROR(req, sys_errno);
req->sys_errno_ = (sys_errno); \
req->errorno = (uv_errno);
#define VERIFY_UV_FILE(file, req) \
if (file == -1) { \
req->result = -1; \
req->errorno = UV_EBADF; \
req->last_error = ERROR_SUCCESS; \
req->sys_errno_ = ERROR_SUCCESS; \
return; \
}
@ -137,7 +133,7 @@ static void uv_fs_req_init_async(uv_loop_t* loop, uv_fs_t* req,
req->path = path ? strdup(path) : NULL;
req->pathw = (wchar_t*)pathw;
req->errorno = 0;
req->last_error = 0;
req->sys_errno_ = 0;
memset(&req->overlapped, 0, sizeof(req->overlapped));
}
@ -266,7 +262,15 @@ void fs__open(uv_fs_t* req, const wchar_t* path, int flags, int mode) {
attributes,
NULL);
if (file == INVALID_HANDLE_VALUE) {
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
DWORD error = GetLastError();
if (error == ERROR_FILE_EXISTS && (flags & _O_CREAT) &&
!(flags & _O_EXCL)) {
/* Special case: when ERROR_FILE_EXISTS happens and O_CREAT was */
/* specified, it means the path referred to a directory. */
SET_REQ_UV_ERROR(req, UV_EISDIR, error);
} else {
SET_REQ_WIN32_ERROR(req, GetLastError());
}
return;
}
result = _open_osfhandle((intptr_t)file, flags);
@ -300,7 +304,7 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
}
if (length > INT_MAX) {
SET_REQ_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
SET_REQ_WIN32_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
return;
}
@ -319,7 +323,7 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
if (ReadFile(handle, buf, length, &bytes, overlapped_ptr)) {
SET_REQ_RESULT(req, bytes);
} else {
SET_REQ_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
}
}
@ -340,7 +344,7 @@ void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
}
if (length > INT_MAX) {
SET_REQ_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
SET_REQ_WIN32_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
return;
}
@ -359,7 +363,7 @@ void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
if (WriteFile(handle, buf, length, &bytes, overlapped_ptr)) {
SET_REQ_RESULT(req, bytes);
} else {
SET_REQ_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
}
}
@ -398,7 +402,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
if (!(GetFileAttributesW(path) & FILE_ATTRIBUTE_DIRECTORY)) {
req->result = -1;
req->errorno = UV_ENOTDIR;
req->last_error = ERROR_SUCCESS;
req->sys_errno_ = ERROR_SUCCESS;
return;
}
@ -416,7 +420,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
free(path2);
if(dir == INVALID_HANDLE_VALUE) {
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
@ -460,7 +464,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
/* Convert result to UTF8. */
size = uv_utf16_to_utf8(buf, buf_char_len, NULL, 0);
if (!size) {
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
@ -474,7 +478,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
free(buf);
free(req->ptr);
req->ptr = NULL;
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
free(buf);
@ -491,7 +495,6 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
static void fs__stat(uv_fs_t* req, const wchar_t* path) {
HANDLE handle;
int result;
BY_HANDLE_FILE_INFORMATION info;
req->ptr = NULL;
@ -504,12 +507,12 @@ static void fs__stat(uv_fs_t* req, const wchar_t* path) {
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
if (handle == INVALID_HANDLE_VALUE) {
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
if (!GetFileInformationByHandle(handle, &info)) {
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
CloseHandle(handle);
return;
}
@ -565,7 +568,7 @@ void fs__fstat(uv_fs_t* req, uv_file file) {
void fs__rename(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path) {
if (!MoveFileExW(path, new_path, MOVEFILE_REPLACE_EXISTING)) {
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
@ -580,7 +583,7 @@ void fs__fsync(uv_fs_t* req, uv_file file) {
result = FlushFileBuffers((HANDLE)_get_osfhandle(file)) ? 0 : -1;
if (result == -1) {
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
} else {
SET_REQ_RESULT(req, result);
}
@ -711,7 +714,7 @@ void fs__futime(uv_fs_t* req, uv_file file, double atime, double mtime) {
void fs__link(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path) {
int result = CreateHardLinkW(new_path, path, NULL) ? 0 : -1;
if (result == -1) {
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
} else {
SET_REQ_RESULT(req, result);
}
@ -726,13 +729,11 @@ void fs__symlink(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path,
path,
flags & UV_FS_SYMLINK_DIR ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) ? 0 : -1;
if (result == -1) {
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
} else {
req->result = -1;
req->errorno = UV_ENOTSUP;
req->last_error = ERROR_SUCCESS;
SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED);
return;
}
@ -761,7 +762,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
if (INVALID_HANDLE_VALUE == symlink) {
result = -1;
SET_REQ_LAST_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
goto done;
}
@ -781,7 +782,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
if (!rv) {
result = -1;
SET_REQ_LAST_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
goto done;
}
@ -789,7 +790,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
if (reparse_data->ReparseTag != IO_REPARSE_TAG_SYMLINK) {
result = -1;
/* something is seriously wrong */
SET_REQ_LAST_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
goto done;
}
@ -810,7 +811,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
0);
if (!utf8size) {
result = -1;
SET_REQ_LAST_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
goto done;
}
@ -825,7 +826,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
utf8size);
if (!utf8size) {
result = -1;
SET_REQ_LAST_ERROR(req, GetLastError());
SET_REQ_WIN32_ERROR(req, GetLastError());
goto done;
}

2
deps/uv/test/test-fs.c

@ -45,7 +45,7 @@
# define close _close
#endif
#define TOO_LONG_NAME_LENGTH 8192
#define TOO_LONG_NAME_LENGTH 65536
typedef struct {
const char* path;

2
doc/about/index.html

@ -130,7 +130,7 @@ console.log('Server running at http://127.0.0.1:1337/');</pre>
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
</ul>
<p>Copyright 2010 <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.6.10/LICENSE">license</a>.</p>
<p>Copyright 2010 <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.6.11/LICENSE">license</a>.</p>
</div>

2
doc/community/index.html

@ -180,7 +180,7 @@
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
</ul>
<p>Copyright 2010 <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.6.10/LICENSE">license</a>.</p>
<p>Copyright 2010 <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.6.11/LICENSE">license</a>.</p>
</div>
<script>

18
doc/index.html

@ -31,7 +31,7 @@
<a href="#download" class="button" id="downloadbutton">Download</a>
<a href="http://nodejs.org/docs/latest/api/index.html" class="button" id="docsbutton">Docs</a>
<p class="version">v0.6.10</p>
<p class="version">v0.6.11</p>
</div>
<div id="quotes" class="clearfix">
<h2>Node.js in the Industry</h2>
@ -78,15 +78,15 @@
<a href="#" id="download-close">X</a>
<img id="download-logo" src="download-logo.png" alt="node.js">
<ul id="installers" class="clearfix">
<li><a href="http://nodejs.org/dist/v0.6.10/node-v0.6.10.msi">Windows Installer</a><br>node-v0.6.10.msi</li>
<li><a href="http://nodejs.org/dist/v0.6.10/node-v0.6.10.pkg">Macintosh Installer</a><br>node-v0.6.10.pkg</li>
<li id="source"><a href="http://nodejs.org/dist/v0.6.10/node-v0.6.10.tar.gz">Source Code</a><br>node-v0.6.10.tar.gz</li>
<li><a href="http://nodejs.org/dist/v0.6.11/node-v0.6.11.msi">Windows Installer</a><br>node-v0.6.11.msi</li>
<li><a href="http://nodejs.org/dist/v0.6.11/node-v0.6.11.pkg">Macintosh Installer</a><br>node-v0.6.11.pkg</li>
<li id="source"><a href="http://nodejs.org/dist/v0.6.11/node-v0.6.11.tar.gz">Source Code</a><br>node-v0.6.11.tar.gz</li>
</ul>
<ul id="documentation">
<li><a href="https://raw.github.com/joyent/node/v0.6.10/ChangeLog">Change Log</a></li>
<li><a href="http://nodejs.org/docs/v0.6.10/api/index.html">Documentation</a></li>
<li><a href="http://nodejs.org/dist/v0.6.10">Other release files</a></li>
<li><a href="https://raw.github.com/joyent/node/v0.6.10/LICENSE">License</a></li>
<li><a href="https://raw.github.com/joyent/node/v0.6.11/ChangeLog">Change Log</a></li>
<li><a href="http://nodejs.org/docs/v0.6.11/api/index.html">Documentation</a></li>
<li><a href="http://nodejs.org/dist/v0.6.11">Other release files</a></li>
<li><a href="https://raw.github.com/joyent/node/v0.6.11/LICENSE">License</a></li>
<li><a href="https://github.com/joyent/node">Git Repository</a></li>
<li><a href="https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager">Installing
with a Package Manager</a>
@ -211,7 +211,7 @@ server.listen(1337, "127.0.0.1");</pre>
<!-- <li><a hrfe="http://twitter.com/nodejs" class="twitter">@nodejs</a></li> -->
</ul>
<p>Copyright 2010 <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.6.10/LICENSE">license</a>.</p>
<p>Copyright 2010 <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.6.11/LICENSE">license</a>.</p>
</div>

2
doc/logos/index.html

@ -82,7 +82,7 @@
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
</ul>
<p>Copyright <a href="http://joyent.com">Joyent, Inc</a>., Node.js is a <a href="/trademark-policy.pdf">trademark of Joyent, Inc</a>., <a href="https://raw.github.com/joyent/node/v0.6.10/LICENSE">View License</a></p>
<p>Copyright <a href="http://joyent.com">Joyent, Inc</a>., Node.js is a <a href="/trademark-policy.pdf">trademark of Joyent, Inc</a>., <a href="https://raw.github.com/joyent/node/v0.6.11/LICENSE">View License</a></p>
</div>
<script>

6
doc/template.html

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{section}}Node.js v0.6.10 Manual &amp; Documentation</title>
<title>{{section}}Node.js v0.6.11 Manual &amp; Documentation</title>
<link rel="stylesheet" href="assets/style.css">
<link rel="stylesheet" href="assets/sh.css">
<link rel="canonical" href="http://nodejs.org/docs/latest/api/{{filename}}.html">
@ -31,7 +31,7 @@
<div id="column1" class="interior">
<header>
<h1>Node.js v0.6.10 Manual &amp; Documentation</h1>
<h1>Node.js v0.6.11 Manual &amp; Documentation</h1>
<div id="gtoc">
<p><a href="index.html" name="toc">Index</a> | <a href="all.html">View on single page</a></p>
</div>
@ -54,7 +54,7 @@
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
</ul>
<p>Copyright 2010 <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.6.10/LICENSE">license</a>.</p>
<p>Copyright 2010 <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.6.11/LICENSE">license</a>.</p>
</div>
<script src="assets/sh_main.js"></script>

24
lib/net.js

@ -756,26 +756,14 @@ Server.prototype._listen2 = function(address, port, addressType) {
function listen(self, address, port, addressType) {
if (!process.env.NODE_WORKER_ID) {
if (process.env.NODE_WORKER_ID) {
require('cluster')._getServer(address, port, addressType, function(handle) {
self._handle = handle;
self._listen2(address, port, addressType);
});
} else {
self._listen2(address, port, addressType);
return;
}
require('cluster')._getServer(address, port, addressType, function(handle) {
// OS X doesn't necessarily signal EADDRINUSE from bind(), it may defer
// the error until later. libuv mimics this behaviour to provide
// consistent behaviour across platforms but that means we could very
// well have a socket that is not actually bound... that's why we do
// this ghetto port check and raise EADDRINUSE if the requested and the
// actual port differ except if port == 0 because that means "any port".
if (port && port != handle.getsockname().port) {
self.emit('error', errnoException('EADDRINUSE', 'bind'));
return;
}
self._handle = handle;
self._listen2(address, port, addressType);
});
}

2
src/node_version.h

@ -28,7 +28,7 @@
#define NODE_MAJOR_VERSION 0
#define NODE_MINOR_VERSION 6
#define NODE_PATCH_VERSION 11
#define NODE_PATCH_VERSION 12
#define NODE_VERSION_IS_RELEASE 0
#ifndef NODE_STRINGIFY

77
test/simple/test-cluster-bind-twice-v1.js

@ -1,77 +0,0 @@
// 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 test starts two clustered HTTP servers on the same port. It expects the
// first cluster to succeed and the second cluster to fail with EADDRINUSE.
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
var fork = require('child_process').fork;
var http = require('http');
var id = process.argv[2];
if (!id) {
var a = fork(__filename, ['one']);
var b = fork(__filename, ['two']);
a.on('message', function(m) {
assert.equal(m, 'READY');
b.send('START');
});
var ok = false;
b.on('message', function(m) {
assert.equal(m, 'EADDRINUSE');
a.kill();
b.kill();
ok = true;
});
process.on('exit', function() {
a.kill();
b.kill();
assert(ok);
});
}
else if (id === 'one') {
if (cluster.isMaster) cluster.fork();
http.createServer(assert.fail).listen(common.PORT, function() {
process.send('READY');
});
}
else if (id === 'two') {
if (cluster.isMaster) cluster.fork();
process.on('message', function(m) {
assert.equal(m, 'START');
var server = http.createServer(assert.fail);
server.listen(common.PORT, assert.fail);
server.on('error', function(e) {
assert.equal(e.code, 'EADDRINUSE');
process.send(e.code);
});
});
}
else {
assert(0); // bad command line argument
}

115
test/simple/test-cluster-bind-twice-v2.js

@ -1,115 +0,0 @@
// 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 test starts two clustered HTTP servers on the same port. It expects the
// first cluster to succeed and the second cluster to fail with EADDRINUSE.
//
// The test may seem complex but most of it is plumbing that routes messages
// from the child processes back to the "super" master. As a tree it looks
// something like this:
//
// <super master>
// / \
// <master 1> <master 2>
// / \
// <worker 1> <worker 2>
//
// The first worker starts a server on a fixed port and fires a ready message
// that is routed to the second worker. When it tries to bind, it expects to
// see an EADDRINUSE error.
//
// See https://github.com/joyent/node/issues/2721 for more details.
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
var fork = require('child_process').fork;
var http = require('http');
var id = process.argv[2];
if (!id) {
var a = fork(__filename, ['one']);
var b = fork(__filename, ['two']);
a.on('message', function(m) {
if (typeof m === 'object') return;
assert.equal(m, 'READY');
b.send('START');
});
var ok = false;
b.on('message', function(m) {
if (typeof m === 'object') return; // ignore system messages
assert.equal(m, 'EADDRINUSE');
a.kill();
b.kill();
ok = true;
});
process.on('exit', function() {
a.kill();
b.kill();
assert(ok);
});
}
else if (id === 'one') {
if (cluster.isMaster) return startWorker();
http.createServer(assert.fail).listen(common.PORT, function() {
process.send('READY');
});
}
else if (id === 'two') {
if (cluster.isMaster) return startWorker();
var ok = false;
process.on('SIGTERM', process.exit);
process.on('exit', function() {
assert(ok);
});
process.on('message', function(m) {
if (typeof m === 'object') return; // ignore system messages
assert.equal(m, 'START');
var server = http.createServer(assert.fail);
server.listen(common.PORT, assert.fail);
server.on('error', function(e) {
assert.equal(e.code, 'EADDRINUSE');
process.send(e.code);
ok = true;
});
});
}
else {
assert(0); // bad command line argument
}
function startWorker() {
var worker = cluster.fork();
worker.on('message', process.send);
process.on('message', worker.send.bind(worker));
process.on('SIGTERM', function() {
worker.kill();
process.exit();
});
}
Loading…
Cancel
Save