Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
uv: upgrade to 41e8574
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Oct 10, 2011
1 parent 326ba25 commit 025f5c8
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 20 deletions.
10 changes: 3 additions & 7 deletions deps/uv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ http://nodejs.org/

## Features

Implemented:

* Non-blocking TCP sockets

* Non-blocking named pipes
Expand All @@ -32,13 +30,11 @@ Implemented:

* ANSI escape code controlled TTY `uv_tty_t`

In-progress:

* File system events (Currently supports inotify, `ReadDirectoryChangesW`
and will support kqueue and event ports in the near future.)
* File system events Currently supports inotify, `ReadDirectoryChangesW`
and kqueue. Event ports in the near future.
`uv_fs_event_t`

* Socket sharing between processes `uv_ipc_t`
* IPC and socket sharing between processes `uv_write2`


## Documentation
Expand Down
17 changes: 9 additions & 8 deletions deps/uv/src/unix/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ void uv_fs_req_cleanup(uv_fs_t* req) {

switch (req->fs_type) {
case UV_FS_READDIR:
assert((req->result == -1 && req->ptr == NULL)
|| (req->result >= 0 && req->ptr != NULL));
assert(req->result > 0 ? (req->ptr != NULL) : (req->ptr == NULL));
free(req->ptr);
req->ptr = NULL;
break;
Expand Down Expand Up @@ -116,9 +115,6 @@ static int uv__fs_after(eio_req* eio) {

switch (req->fs_type) {
case UV_FS_READDIR:
if (req->eio->result == -1)
break; /* opendir() or readdir() operation failed. */

/*
* XXX This is pretty bad.
* We alloc and copy the large null terminated string list from libeio.
Expand All @@ -128,16 +124,21 @@ static int uv__fs_after(eio_req* eio) {
*/
buflen = 0;
name = req->eio->ptr2;

for (i = 0; i < req->result; i++) {
namelen = strlen(name);
buflen += namelen + 1;
/* TODO check ENOMEM */
name += namelen;
assert(*name == '\0');
name++;
}
req->ptr = malloc(buflen);
memcpy(req->ptr, req->eio->ptr2, buflen);

if (buflen) {
if ((req->ptr = malloc(buflen)))
memcpy(req->ptr, req->eio->ptr2, buflen);
else
uv__set_sys_error(req->loop, ENOMEM);
}
break;

case UV_FS_STAT:
Expand Down
60 changes: 55 additions & 5 deletions deps/uv/test/test-fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static void fchmod_cb(uv_fs_t* req) {
ASSERT(req->result == 0);
fchmod_cb_count++;
uv_fs_req_cleanup(req);
check_permission("test_file", (int)req->data);
check_permission("test_file", *(int*)req->data);
}


Expand All @@ -164,7 +164,7 @@ static void chmod_cb(uv_fs_t* req) {
ASSERT(req->result == 0);
chmod_cb_count++;
uv_fs_req_cleanup(req);
check_permission("test_file", (int)req->data);
check_permission("test_file", *(int*)req->data);
}


Expand Down Expand Up @@ -354,6 +354,16 @@ static void readdir_cb(uv_fs_t* req) {
}


static void empty_readdir_cb(uv_fs_t* req) {
ASSERT(req == &readdir_req);
ASSERT(req->fs_type == UV_FS_READDIR);
ASSERT(req->result == 0);
ASSERT(req->ptr == NULL);
uv_fs_req_cleanup(req);
readdir_cb_count++;
}


static void stat_cb(uv_fs_t* req) {
ASSERT(req == &stat_req);
ASSERT(req->fs_type == UV_FS_STAT || req->fs_type == UV_FS_LSTAT);
Expand Down Expand Up @@ -869,7 +879,10 @@ TEST_IMPL(fs_chmod) {

#ifndef _WIN32
/* async chmod */
req.data = (void*)0200;
{
static int mode = 0200;
req.data = &mode;
}
r = uv_fs_chmod(loop, &req, "test_file", 0200, chmod_cb);
ASSERT(r == 0);
uv_run(loop);
Expand All @@ -878,14 +891,20 @@ TEST_IMPL(fs_chmod) {
#endif

/* async chmod */
req.data = (void*)0400;
{
static int mode = 0400;
req.data = &mode;
}
r = uv_fs_chmod(loop, &req, "test_file", 0400, chmod_cb);
ASSERT(r == 0);
uv_run(loop);
ASSERT(chmod_cb_count == 1);

/* async fchmod */
req.data = (void*)0600;
{
static int mode = 0600;
req.data = &mode;
}
r = uv_fs_fchmod(loop, &req, file, 0600, fchmod_cb);
ASSERT(r == 0);
uv_run(loop);
Expand Down Expand Up @@ -1283,3 +1302,34 @@ TEST_IMPL(fs_stat_missing_path) {

return 0;
}


TEST_IMPL(fs_readdir_empty_dir) {
const char* path;
uv_fs_t req;
int r;

path = "./empty_dir/";
loop = uv_default_loop();

uv_fs_mkdir(loop, &req, path, 0777, NULL);
uv_fs_req_cleanup(&req);

r = uv_fs_readdir(loop, &req, path, 0, NULL);
ASSERT(r == 0);
ASSERT(req.result == 0);
ASSERT(req.ptr == NULL);
uv_fs_req_cleanup(&req);

r = uv_fs_readdir(loop, &readdir_req, path, 0, empty_readdir_cb);
ASSERT(r == 0);

ASSERT(readdir_cb_count == 0);
uv_run(loop);
ASSERT(readdir_cb_count == 1);

uv_fs_rmdir(loop, &req, path, NULL);
uv_fs_req_cleanup(&req);

return 0;
}
2 changes: 2 additions & 0 deletions deps/uv/test/test-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ TEST_DECLARE (fs_stat_missing_path)
TEST_DECLARE (fs_event_watch_dir)
TEST_DECLARE (fs_event_watch_file)
TEST_DECLARE (fs_event_watch_file_current_dir)
TEST_DECLARE (fs_readdir_empty_dir)
TEST_DECLARE (threadpool_queue_work_simple)
#ifdef _WIN32
TEST_DECLARE (spawn_detect_pipe_name_collisions_on_windows)
Expand Down Expand Up @@ -232,6 +233,7 @@ TASK_LIST_START
TEST_ENTRY (fs_event_watch_dir)
TEST_ENTRY (fs_event_watch_file)
TEST_ENTRY (fs_event_watch_file_current_dir)
TEST_ENTRY (fs_readdir_empty_dir)

TEST_ENTRY (threadpool_queue_work_simple)

Expand Down

0 comments on commit 025f5c8

Please sign in to comment.