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

Commit

Permalink
Upgrade libuv to 1997e10b50
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Nov 5, 2011
1 parent 5c3954a commit b54da8a
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 34 deletions.
32 changes: 26 additions & 6 deletions deps/uv/include/uv.h
Expand Up @@ -763,7 +763,7 @@ UV_EXTERN void uv_pipe_open(uv_pipe_t*, uv_file file);

UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name);

UV_EXTERN int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
UV_EXTERN void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
const char* name, uv_connect_cb cb);


Expand Down Expand Up @@ -1166,13 +1166,33 @@ struct uv_fs_event_s {
*/
UV_EXTERN void uv_loadavg(double avg[3]);


/*
* If filename is a directory then we will watch for all events in that
* directory. If filename is a file - we will only get events from that
* file. Subdirectories are not watched.
*/
* Flags to be passed to uv_fs_event_init.
*/
enum uv_fs_event_flags {
/*
* By default, if the fs event watcher is given a directory name, we will
* watch for all events in that directory. This flags overrides this behavior
* and makes fs_event report only changes to the directory entry itself. This
* flag does not affect individual files watched.
* This flag is currently not implemented yet on any backend.
*/
UV_FS_EVENT_WATCH_ENTRY = 1,

/*
* By default uv_fs_event will try to use a kernel interface such as inotify
* or kqueue to detect events. This may not work on remote filesystems such
* as NFS mounts. This flag makes fs_event fall back to calling stat() on a
* regular interval.
* This flag is currently not implemented yet on any backend.
*/
UV_FS_EVENT_STAT = 2
};


UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
const char* filename, uv_fs_event_cb cb);
const char* filename, uv_fs_event_cb cb, int flags);

/* Utility */

Expand Down
3 changes: 2 additions & 1 deletion deps/uv/src/unix/cygwin.c
Expand Up @@ -69,7 +69,8 @@ uint64_t uv_get_total_memory(void) {
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv_fs_event_cb cb,
int flags) {
uv__set_sys_error(loop, ENOSYS);
return -1;
}
Expand Down
9 changes: 7 additions & 2 deletions deps/uv/src/unix/kqueue.c
Expand Up @@ -86,9 +86,13 @@ void uv__kqueue_hack(EV_P_ int fflags, ev_io *w) {
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv_fs_event_cb cb,
int flags) {
int fd;

/* We don't support any flags yet. */
assert(!flags);

if (cb == NULL) {
uv__set_sys_error(loop, EINVAL);
return -1;
Expand Down Expand Up @@ -122,7 +126,8 @@ void uv__fs_event_destroy(uv_fs_event_t* handle) {
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv_fs_event_cb cb,
int flags) {
uv__set_sys_error(loop, ENOSYS);
return -1;
}
Expand Down
6 changes: 5 additions & 1 deletion deps/uv/src/unix/linux.c
Expand Up @@ -156,10 +156,14 @@ static void uv__inotify_read(EV_P_ ev_io* w, int revents) {
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv_fs_event_cb cb,
int flags) {
int flags;
int fd;

/* We don't support any flags yet. */
assert(!flags);

/*
* TODO share a single inotify fd across the event loop?
* We'll run into fs.inotify.max_user_instances if we
Expand Down
3 changes: 1 addition & 2 deletions deps/uv/src/unix/pipe.c
Expand Up @@ -177,7 +177,7 @@ void uv_pipe_open(uv_pipe_t* handle, uv_file fd) {
}


int uv_pipe_connect(uv_connect_t* req,
void uv_pipe_connect(uv_connect_t* req,
uv_pipe_t* handle,
const char* name,
uv_connect_cb cb) {
Expand Down Expand Up @@ -237,7 +237,6 @@ int uv_pipe_connect(uv_connect_t* req,
* return 0 and let the callback handle errors.
*/
errno = saved_errno;
return 0;
}


Expand Down
6 changes: 5 additions & 1 deletion deps/uv/src/unix/sunos.c
Expand Up @@ -137,9 +137,13 @@ static void uv__fs_event_read(EV_P_ ev_io* w, int revents) {
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv_fs_event_cb cb,
int flags) {
int portfd;

/* We don't support any flags yet. */
assert(!flags);

if ((portfd = port_create()) == -1) {
uv__set_sys_error(loop, errno);
return -1;
Expand Down
5 changes: 4 additions & 1 deletion deps/uv/src/win/fs-event.c
Expand Up @@ -133,12 +133,15 @@ static int uv_split_path(const wchar_t* filename, wchar_t** dir,


int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
const char* filename, uv_fs_event_cb cb) {
const char* filename, uv_fs_event_cb cb, int flags) {
int name_size;
DWORD attr, last_error;
wchar_t* dir = NULL, *dir_to_watch, *filenamew;
wchar_t short_path[MAX_PATH];

/* We don't support any flags yet. */
assert(!flags);

uv_fs_event_init_handle(loop, handle, filename, cb);

/* Convert name to UTF16. */
Expand Down
14 changes: 9 additions & 5 deletions deps/uv/src/win/pipe.c
Expand Up @@ -443,7 +443,7 @@ static DWORD WINAPI pipe_connect_thread_proc(void* parameter) {
}


int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
const char* name, uv_connect_cb cb) {
uv_loop_t* loop = handle->loop;
int errno, nameSize;
Expand Down Expand Up @@ -488,7 +488,7 @@ int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,

handle->reqs_pending++;

return 0;
return;
}

errno = GetLastError();
Expand All @@ -505,7 +505,7 @@ int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
SET_REQ_SUCCESS(req);
uv_insert_pending_req(loop, (uv_req_t*) req);
handle->reqs_pending++;
return 0;
return;

error:
if (handle->name) {
Expand All @@ -516,8 +516,12 @@ int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
if (pipeHandle != INVALID_HANDLE_VALUE) {
CloseHandle(pipeHandle);
}
uv__set_sys_error(loop, errno);
return -1;

/* Make this req pending reporting an error. */
SET_REQ_ERROR(req, errno);
uv_insert_pending_req(loop, (uv_req_t*) req);
handle->reqs_pending++;
return;
}


Expand Down
7 changes: 1 addition & 6 deletions deps/uv/test/benchmark-pound.c
Expand Up @@ -225,12 +225,7 @@ static void pipe_make_connect(conn_rec* p) {
r = uv_pipe_init(loop, (uv_pipe_t*)&p->stream, 0);
ASSERT(r == 0);

r = uv_pipe_connect(&((pipe_conn_rec*)p)->conn_req, (uv_pipe_t*)&p->stream, TEST_PIPENAME, connect_cb);
if (r) {
fprintf(stderr, "uv_tcp_connect error %s\n",
uv_err_name(uv_last_error(loop)));
ASSERT(0);
}
uv_pipe_connect(&((pipe_conn_rec*)p)->conn_req, (uv_pipe_t*)&p->stream, TEST_PIPENAME, connect_cb);

#if DEBUG
printf("make connect %d\n", p->i);
Expand Down
3 changes: 1 addition & 2 deletions deps/uv/test/benchmark-pump.c
Expand Up @@ -257,8 +257,7 @@ static void maybe_connect_some() {
ASSERT(r == 0);

req = (uv_connect_t*) req_alloc();
r = uv_pipe_connect(req, pipe, TEST_PIPENAME, connect_cb);
ASSERT(r == 0);
uv_pipe_connect(req, pipe, TEST_PIPENAME, connect_cb);
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions deps/uv/test/test-fs-event.c
Expand Up @@ -144,7 +144,7 @@ TEST_IMPL(fs_event_watch_dir) {
uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL);
create_dir(loop, "watch_dir");

r = uv_fs_event_init(loop, &fs_event, "watch_dir", fs_event_cb_dir);
r = uv_fs_event_init(loop, &fs_event, "watch_dir", fs_event_cb_dir, 0);
ASSERT(r != -1);
r = uv_timer_init(loop, &timer);
ASSERT(r != -1);
Expand Down Expand Up @@ -178,7 +178,7 @@ TEST_IMPL(fs_event_watch_file) {
create_file(loop, "watch_dir/file1");
create_file(loop, "watch_dir/file2");

r = uv_fs_event_init(loop, &fs_event, "watch_dir/file2", fs_event_cb_file);
r = uv_fs_event_init(loop, &fs_event, "watch_dir/file2", fs_event_cb_file, 0);
ASSERT(r != -1);
r = uv_timer_init(loop, &timer);
ASSERT(r != -1);
Expand Down Expand Up @@ -212,7 +212,7 @@ TEST_IMPL(fs_event_watch_file_current_dir) {
create_file(loop, "watch_file");

r = uv_fs_event_init(loop, &fs_event, "watch_file",
fs_event_cb_file_current_dir);
fs_event_cb_file_current_dir, 0);
ASSERT(r != -1);

r = uv_timer_init(loop, &timer);
Expand Down Expand Up @@ -248,7 +248,11 @@ TEST_IMPL(fs_event_no_callback_on_close) {
create_dir(loop, "watch_dir");
create_file(loop, "watch_dir/file1");

r = uv_fs_event_init(loop, &fs_event, "watch_dir/file1", fs_event_cb_file);
r = uv_fs_event_init(loop,
&fs_event,
"watch_dir/file1",
fs_event_cb_file,
0);
ASSERT(r != -1);

uv_close((uv_handle_t*)&fs_event, close_cb);
Expand Down
3 changes: 1 addition & 2 deletions deps/uv/test/test-ping-pong.c
Expand Up @@ -211,9 +211,8 @@ static void pipe_pinger_new() {
/* We are never doing multiple reads/connects at a time anyway. */
/* so these handles can be pre-initialized. */

r = uv_pipe_connect(&pinger->connect_req, &pinger->stream.pipe, TEST_PIPENAME,
uv_pipe_connect(&pinger->connect_req, &pinger->stream.pipe, TEST_PIPENAME,
pinger_on_connect);
ASSERT(!r);

/* Synchronous connect callbacks are not allowed. */
ASSERT(pinger_on_connect_count == 0);
Expand Down
1 change: 0 additions & 1 deletion deps/uv/test/test-pipe-connect-error.c
Expand Up @@ -58,7 +58,6 @@ TEST_IMPL(pipe_connect_bad_name) {
r = uv_pipe_init(uv_default_loop(), &client, 0);
ASSERT(r == 0);
uv_pipe_connect(&req, &client, BAD_PIPENAME, connect_cb);
ASSERT(r == 0);

uv_run(uv_default_loop());

Expand Down

0 comments on commit b54da8a

Please sign in to comment.