Skip to content

Commit

Permalink
Merge remote-tracking branch 'ry/v0.6'
Browse files Browse the repository at this point in the history
Conflicts:
	ChangeLog
	deps/v8/src/version.cc
	deps/v8/tools/gyp/v8.gyp
	doc/about/index.html
	doc/community/index.html
	doc/index.html
	doc/logos/index.html
	doc/template.html
	lib/path.js
	lib/querystring.js
	src/node_version.h
  • Loading branch information
isaacs committed Feb 6, 2012
2 parents e5db01e + 7543c38 commit 1168355
Show file tree
Hide file tree
Showing 22 changed files with 545 additions and 255 deletions.
23 changes: 23 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@
* Bug fixes


2012.02.02, Version 0.6.10 (stable)

* Update V8 to 3.6.6.20

* Add npm msysgit bash shim to msi installer (isaacs)

* buffers: fix intermittent out of bounds error (Ben Noordhuis)

* buffers: honor length argument in base64 decoder (Ben Noordhuis)

* windows: Fix path.exists regression (Bert Belder)

* Make QueryString.parse run faster (Philip Tellis)

* http: avoid freeing http-parser objects too early (koichik)

* timers: add v0.4 compatibility hack (Ben Noordhuis)

* Proper EPERM error code support (Igor Zinkovsky, Brandon Philips)

* dgram: Implement udp multicast methods on windows (Bert Belder)


2012.01.27, Version 0.6.9 (stable), f19e20d33f57c4d2853aaea7d2724d44f3b0012f

* dgram: Bring back missing functionality for Unix (Dan VerWeire, Roman Shtylman, Ben Noordhuis)
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/src/win/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case ERROR_SUCCESS: return UV_OK;
case ERROR_FILE_NOT_FOUND: return UV_ENOENT;
case ERROR_PATH_NOT_FOUND: return UV_ENOENT;
case ERROR_ACCESS_DENIED: return UV_EACCES;
case ERROR_ACCESS_DENIED: return UV_EPERM;
case ERROR_NOACCESS: return UV_EACCES;
case WSAEACCES: return UV_EACCES;
case ERROR_ADDRESS_ALREADY_ASSOCIATED: return UV_EADDRINUSE;
Expand Down
184 changes: 27 additions & 157 deletions deps/uv/src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,191 +489,61 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
}


#define IS_SLASH(c) \
((wchar_t) c == L'/' || (wchar_t) c == L'\\')
#define IS_COLON(c) \
((wchar_t) c == L':')
#define IS_LETTER(c) \
((((wchar_t) c >= L'a') && ((wchar_t) c <= L'z')) || \
(((wchar_t) c >= L'A') && ((wchar_t) c <= L'Z')))
#define IS_QUESTION(c) \
((wchar_t) c == L'?')


static int uv__count_slash_separated_words(const wchar_t* pos,
const wchar_t* end,
int limit) {
char last_was_slash = 1, count = 0;

for (; pos < end; pos++) {
if (IS_SLASH(*pos)) {
/* Don't accept double slashes */
if (last_was_slash) {
return 0;
} else {
last_was_slash = 1;
}
} else {
if (last_was_slash) {
/* Found a new word */
count++;
if (count > limit) {
return -1;
}
last_was_slash = 0;
}
}
}

return count;
}

/*
* Returns true if the given path is a root directory. The following patterns
* are recognized:
* \
* c:\ (must have trailing slash)
* \\server\share (trailing slash optional)
* \\?\c: (trailing slash optional)
* \\?\UNC\server\share (trailing slash optional)
*/
static int uv__is_root(const wchar_t* path) {
size_t len = wcslen(path);

/* Test for \ */
if (len == 1 && IS_SLASH(path[0])) {
return 1;
}

if (len < 3) {
return 0;
}

/* Test for c:\ */
if (IS_LETTER(path[0]) && IS_COLON(path[1]) && IS_SLASH(path[2])) {
return 1;
}

if (!IS_SLASH(path[0]) || !IS_SLASH(path[1])) {
return 0;
}

/* Test for \\server\share */
if (!IS_QUESTION(path[2])) {
return uv__count_slash_separated_words(path + 2, path + len, 2) == 2;
}

if (!IS_SLASH(path[3])) {
return 0;
}

if ((len == 6 || len == 7) &&
IS_LETTER(path[4]) && IS_COLON(path[5]) &&
(len == 6 || IS_SLASH(path[6]))) {
return 1;
}

/* Test for \\?\UNC\server\share */
if (len >= 8 &&
(path[4] == L'u' || path[4] == L'U') &&
(path[5] == L'n' || path[5] == L'N') &&
(path[6] == L'c' || path[6] == L'C') &&
IS_SLASH(path[7])) {
return uv__count_slash_separated_words(path + 8, path + len, 2) == 2;
}

return 0;
}


void fs__stat(uv_fs_t* req, const wchar_t* path) {
HANDLE file;
WIN32_FIND_DATAW ent;
static void fs__stat(uv_fs_t* req, const wchar_t* path) {
HANDLE handle;
int result;
BY_HANDLE_FILE_INFORMATION info;

req->ptr = NULL;

if (uv__is_root(path)) {
/* We can't stat root directories like c:\. _wstati64 can't either, but */
/* it will make up something reasonable. */
DWORD drive_type = GetDriveTypeW(path);
if (drive_type == DRIVE_UNKNOWN || drive_type == DRIVE_NO_ROOT_DIR) {
req->last_error = ERROR_PATH_NOT_FOUND;
req->errorno = UV_ENOENT;
req->result = -1;
return;
}

memset(&req->stat, 0, sizeof req->stat);

req->stat.st_nlink = 1;
req->stat.st_mode = ((_S_IREAD|_S_IWRITE) + ((_S_IREAD|_S_IWRITE) >> 3) +
((_S_IREAD|_S_IWRITE) >> 6)) | S_IFDIR;

req->last_error = ERROR_SUCCESS;
req->errorno = UV_OK;
req->result = 0;
req->ptr = &req->stat;
handle = CreateFileW(path,
FILE_READ_ATTRIBUTES,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
if (handle == INVALID_HANDLE_VALUE) {
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
return;
}

file = FindFirstFileExW(path, FindExInfoStandard, &ent,
FindExSearchNameMatch, NULL, 0);

if (file == INVALID_HANDLE_VALUE) {
if (!GetFileInformationByHandle(handle, &info)) {
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
CloseHandle(handle);
return;
}

FindClose(file);

if (ent.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT &&
ent.dwReserved0 == IO_REPARSE_TAG_SYMLINK) {
fs__open(req, path, _O_RDONLY, 0);
if (req->result != -1) {
result = _fstati64(req->result, &req->stat);
_close(req->result);

if (result != -1) {
req->ptr = &req->stat;
}

SET_REQ_RESULT(req, result);
}
memset(&req->stat, 0, sizeof req->stat);

return;
}
/* TODO: set st_dev and st_ino? */

req->stat.st_ino = 0;
req->stat.st_uid = 0;
req->stat.st_gid = 0;
req->stat.st_mode = 0;
req->stat.st_rdev = 0;
req->stat.st_dev = 0;
req->stat.st_nlink = 1;

if (ent.dwFileAttributes & FILE_ATTRIBUTE_READONLY ) {
if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
req->stat.st_mode |= (_S_IREAD + (_S_IREAD >> 3) + (_S_IREAD >> 6));
} else {
req->stat.st_mode |= ((_S_IREAD|_S_IWRITE) + ((_S_IREAD|_S_IWRITE) >> 3) +
((_S_IREAD|_S_IWRITE) >> 6));
}

if (ent.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
req->stat.st_mode |= _S_IFDIR;
} else {
req->stat.st_mode |= _S_IFREG;
}

uv_filetime_to_time_t(&ent.ftLastWriteTime, &(req->stat.st_mtime));
uv_filetime_to_time_t(&ent.ftLastAccessTime, &(req->stat.st_atime));
uv_filetime_to_time_t(&ent.ftCreationTime, &(req->stat.st_ctime));
uv_filetime_to_time_t(&info.ftLastWriteTime, &(req->stat.st_mtime));
uv_filetime_to_time_t(&info.ftLastAccessTime, &(req->stat.st_atime));
uv_filetime_to_time_t(&info.ftCreationTime, &(req->stat.st_ctime));

req->stat.st_size = ((int64_t) info.nFileSizeHigh << 32) +
(int64_t) info.nFileSizeLow;

req->stat.st_size = ((int64_t)ent.nFileSizeHigh << 32) +
(int64_t)ent.nFileSizeLow;
req->stat.st_nlink = info.nNumberOfLinks;

req->ptr = &req->stat;
req->result = 0;

CloseHandle(handle);
}


Expand Down
13 changes: 13 additions & 0 deletions deps/uv/test/test-fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,19 @@ TEST_IMPL(fs_stat_root) {
r = uv_fs_stat(loop, &stat_req, "\\", NULL);
ASSERT(r == 0);

r = uv_fs_stat(loop, &stat_req, "..\\..\\..\\..\\..\\..\\..", NULL);
ASSERT(r == 0);

r = uv_fs_stat(loop, &stat_req, "..", NULL);
ASSERT(r == 0);

r = uv_fs_stat(loop, &stat_req, "..\\", NULL);
ASSERT(r == 0);

/* stats the current directory on c: */
r = uv_fs_stat(loop, &stat_req, "c:", NULL);
ASSERT(r == 0);

r = uv_fs_stat(loop, &stat_req, "c:\\", NULL);
ASSERT(r == 0);

Expand Down
22 changes: 17 additions & 5 deletions doc/api/http.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ no limit will be applied.
This object is created internally by a HTTP server -- not by
the user -- and passed as the first argument to a `'request'` listener.

This is an `EventEmitter` with the following events:
The request implements the [Readable Stream](streams.html#readable_Stream)
interface. This is an `EventEmitter` with the following events:

### Event: 'data'

Expand All @@ -167,6 +168,9 @@ argument. The transfer-encoding has been decoded. The
body chunk is a string. The body encoding is set with
`request.setEncoding()`.

Note that the __data will be lost__ if there is no listener when a
`ServerRequest` emits a `'data'` event.

### Event: 'end'

`function () { }`
Expand Down Expand Up @@ -271,7 +275,10 @@ authentication details.
## http.ServerResponse

This object is created internally by a HTTP server--not by the user. It is
passed as the second parameter to the `'request'` event. It is a `Writable Stream`.
passed as the second parameter to the `'request'` event.

The response implements the [Writable Stream](streams.html#writable_Stream)
interface. This is an `EventEmitter` with the following events:

### Event: 'close'

Expand Down Expand Up @@ -601,11 +608,11 @@ event, the entire body will be caught.
}, 10);
});

This is a `Writable Stream`.
Note: Node does not check whether Content-Length and the length of the body
which has been transmitted are equal or not.

This is an `EventEmitter` with the following events:
The request implements the [Writable Stream](streams.html#writable_Stream)
interface. This is an `EventEmitter` with the following events:

### Event 'response'

Expand Down Expand Up @@ -797,14 +804,19 @@ will be called.
This object is created when making a request with `http.request()`. It is
passed to the `'response'` event of the request object.

The response implements the `Readable Stream` interface.
The response implements the [Readable Stream](streams.html#readable_Stream)
interface. This is an `EventEmitter` with the following events:


### Event: 'data'

`function (chunk) { }`

Emitted when a piece of the message body is received.

Note that the __data will be lost__ if there is no listener when a
`ClientResponse` emits a `'data'` event.


### Event: 'end'

Expand Down
3 changes: 3 additions & 0 deletions doc/api/net.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ Emitted when data is received. The argument `data` will be a `Buffer` or
(See the [Readable Stream](streams.html#readable_Stream) section for more
information.)

Note that the __data will be lost__ if there is no listener when a `Socket`
emits a `'data'` event.

#### Event: 'end'

`function () { }`
Expand Down
3 changes: 3 additions & 0 deletions doc/api/streams.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ A `Readable Stream` has the following methods, members, and events.
The `'data'` event emits either a `Buffer` (by default) or a string if
`setEncoding()` was used.

Note that the __data will be lost__ if there is no listener when a
`Readable Stream` emits a `'data'` event.

### Event: 'end'

`function () { }`
Expand Down
Loading

0 comments on commit 1168355

Please sign in to comment.