Browse Source

Upgrade libuv to f20297f

v0.7.4-release
Ryan Dahl 13 years ago
parent
commit
94bedc60f4
  1. 49
      deps/uv/README.md
  2. 14
      deps/uv/include/uv.h
  3. 7
      deps/uv/src/unix/core.c
  4. 1
      deps/uv/src/unix/darwin.c
  5. 6
      deps/uv/src/unix/tty.c
  6. 9
      deps/uv/src/win/getaddrinfo.c
  7. 11
      deps/uv/src/win/tty.c
  8. 2
      deps/uv/test/benchmark-getaddrinfo.c
  9. 2
      deps/uv/test/test-getaddrinfo.c
  10. 4
      deps/uv/test/test-tty.c
  11. 2
      src/tty_wrap.cc

49
deps/uv/README → deps/uv/README.md

@ -1,10 +1,49 @@
This is the new networking layer for Node. Its purpose is to abstract # libuv
IOCP on windows and libev on Unix systems. We intend to eventually contain
all platform differences in this library. libuv is a new platform layer for Node. Its purpose is to abstract IOCP on
windows and libev on Unix systems. We intend to eventually contain all
platform differences in this library.
http://nodejs.org/ http://nodejs.org/
= Build Instructions ## Features
Implemented Features:
* Non-blocking sockets and pipes
* Timers
* UDP
* Child process spawning
* Asynchronous DNS via c-ares or getaddrinfo.
* Asynchronous file system APIs (uv_fs_*)
* High resolution time (uv_hrtime)
* Current executable path look up (uv_exepath)
* Thread pool scheduling (uv_queue_work)
Work in progress:
* File system events (Currently supports inotify, ReadDirectoryChangesW and
will support kqueue and event ports in the near future.)
* TTY support (with VT100 emulation on Windows - work in progress)
* Socket sharing between processes
## Documentation
See `include/uv.h`.
## Build Instructions
For GCC (including MinGW) there are two methods building: via normal For GCC (including MinGW) there are two methods building: via normal
makefiles or via GYP. GYP is a meta-build system which can generate MSVS, makefiles or via GYP. GYP is a meta-build system which can generate MSVS,
@ -38,7 +77,7 @@ Macintosh users run
xcodebuild -project uv.xcodeproj -configuration Release -target All xcodebuild -project uv.xcodeproj -configuration Release -target All
= Supported Platforms ## Supported Platforms
Microsoft Windows operating systems since Windows XP SP2. It can be built Microsoft Windows operating systems since Windows XP SP2. It can be built
with either Visual Studio or MinGW. with either Visual Studio or MinGW.

14
deps/uv/include/uv.h

@ -612,11 +612,6 @@ struct uv_tty_s {
UV_TTY_PRIVATE_FIELDS UV_TTY_PRIVATE_FIELDS
}; };
/*
* Returns 1 if file is associated with a Console/TTY 0 otherwise.
*/
int uv_is_tty(uv_file file);
int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd); int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd);
/* /*
@ -633,6 +628,7 @@ int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
* Used to detect what type of stream should be used with a given file * Used to detect what type of stream should be used with a given file
* descriptor. Usually this will be used during initialization to guess the * descriptor. Usually this will be used during initialization to guess the
* type of the stdio streams. * type of the stdio streams.
* For isatty() functionality use this function and test for UV_TTY.
*/ */
uv_handle_type uv_guess_handle(uv_file file); uv_handle_type uv_guess_handle(uv_file file);
@ -807,8 +803,10 @@ struct uv_getaddrinfo_s {
* *
* Return code 0 means that request is accepted and callback will be called * Return code 0 means that request is accepted and callback will be called
* with result. Other return codes mean that there will not be a callback. * with result. Other return codes mean that there will not be a callback.
* Input arguments may be released after return from this call. Callback * Input arguments may be released after return from this call.
* must not call freeaddrinfo. *
* uv_freeaddrinfo() must be called after completion to free the addrinfo
* structure.
*/ */
int uv_getaddrinfo(uv_loop_t*, int uv_getaddrinfo(uv_loop_t*,
uv_getaddrinfo_t* handle, uv_getaddrinfo_t* handle,
@ -817,6 +815,8 @@ struct uv_getaddrinfo_s {
const char* service, const char* service,
const struct addrinfo* hints); const struct addrinfo* hints);
void uv_freeaddrinfo(struct addrinfo* ai);
/* uv_spawn() options */ /* uv_spawn() options */
typedef struct uv_process_options_s { typedef struct uv_process_options_s {
uv_exit_cb exit_cb; /* Called after the process exits. */ uv_exit_cb exit_cb; /* Called after the process exits. */

7
deps/uv/src/unix/core.c

@ -600,8 +600,6 @@ static int uv_getaddrinfo_done(eio_req* req) {
handle->cb(handle, handle->retcode, res); handle->cb(handle, handle->retcode, res);
freeaddrinfo(res);
return 0; return 0;
} }
@ -668,6 +666,11 @@ int uv_getaddrinfo(uv_loop_t* loop,
} }
void uv_freeaddrinfo(struct addrinfo* ai) {
freeaddrinfo(ai);
}
/* Open a socket in non-blocking close-on-exec mode, atomically if possible. */ /* Open a socket in non-blocking close-on-exec mode, atomically if possible. */
int uv__socket(int domain, int type, int protocol) { int uv__socket(int domain, int type, int protocol) {
#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC) #if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC)

1
deps/uv/src/unix/darwin.c

@ -19,6 +19,7 @@
*/ */
#include "uv.h" #include "uv.h"
#include "internal.h"
#include <assert.h> #include <assert.h>
#include <stdint.h> #include <stdint.h>

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

@ -26,6 +26,7 @@
#include <unistd.h> #include <unistd.h>
#include <termios.h> #include <termios.h>
#include <errno.h> #include <errno.h>
#include <sys/ioctl.h>
int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd) { int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd) {
@ -69,11 +70,6 @@ fatal:
} }
int uv_is_tty(uv_file file) {
return isatty(file);
}
int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) { int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) {
struct winsize ws; struct winsize ws;

9
deps/uv/src/win/getaddrinfo.c

@ -216,12 +216,17 @@ complete:
/* finally do callback with converted result */ /* finally do callback with converted result */
handle->getaddrinfo_cb(handle, uv_ret, (struct addrinfo*)alloc_ptr); handle->getaddrinfo_cb(handle, uv_ret, (struct addrinfo*)alloc_ptr);
uv_unref(loop);
}
void uv_freeaddrinfo(struct addrinfo* ai) {
char* alloc_ptr = (char*)ai;
/* release copied result memory */ /* release copied result memory */
if (alloc_ptr != NULL) { if (alloc_ptr != NULL) {
free(alloc_ptr); free(alloc_ptr);
} }
uv_unref(loop);
} }

11
deps/uv/src/win/tty.c

@ -38,9 +38,6 @@ int uv_tty_set_mode(uv_tty_t* tty, int mode) {
int uv_is_tty(uv_file file) { int uv_is_tty(uv_file file) {
DWORD result;
int r = GetConsoleMode((HANDLE)_get_osfhandle(file), &result);
return r ? 1 : 0;
} }
@ -51,6 +48,14 @@ int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) {
uv_handle_type uv_guess_handle(uv_file file) { uv_handle_type uv_guess_handle(uv_file file) {
DWORD result;
int r = GetConsoleMode((HANDLE)_get_osfhandle(file), &result);
if (r) {
return UV_TTY;
}
assert(0 && "implement me"); assert(0 && "implement me");
return UV_UNKNOWN_HANDLE; return UV_UNKNOWN_HANDLE;
} }

2
deps/uv/test/benchmark-getaddrinfo.c

@ -52,6 +52,8 @@ static void getaddrinfo_cb(uv_getaddrinfo_t* handle, int status,
if (calls_initiated < TOTAL_CALLS) { if (calls_initiated < TOTAL_CALLS) {
getaddrinfo_initiate(handle); getaddrinfo_initiate(handle);
} }
uv_freeaddrinfo(res);
} }

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

@ -45,6 +45,7 @@ static void getaddrinfo_basic_cb(uv_getaddrinfo_t* handle,
ASSERT(handle == getaddrinfo_handle); ASSERT(handle == getaddrinfo_handle);
getaddrinfo_cbs++; getaddrinfo_cbs++;
free(handle); free(handle);
uv_freeaddrinfo(res);
} }
@ -65,6 +66,7 @@ static void getaddrinfo_cuncurrent_cb(uv_getaddrinfo_t* handle,
ASSERT (i < CONCURRENT_COUNT); ASSERT (i < CONCURRENT_COUNT);
free(data); free(data);
uv_freeaddrinfo(res);
getaddrinfo_cbs++; getaddrinfo_cbs++;
} }

4
deps/uv/test/test-tty.c

@ -31,13 +31,11 @@ TEST_IMPL(tty) {
* Not necessarally a problem if this assert goes off. E.G you are piping * Not necessarally a problem if this assert goes off. E.G you are piping
* this test to a file. 0 == stdin. * this test to a file. 0 == stdin.
*/ */
ASSERT(uv_is_tty(0) == 1); ASSERT(UV_TTY == uv_guess_handle(0));
r = uv_tty_init(uv_default_loop(), &tty, 0); r = uv_tty_init(uv_default_loop(), &tty, 0);
ASSERT(r == 0); ASSERT(r == 0);
ASSERT(UV_TTY == uv_guess_handle(0));
r = uv_tty_get_winsize(&tty, &width, &height); r = uv_tty_get_winsize(&tty, &width, &height);
ASSERT(r == 0); ASSERT(r == 0);

2
src/tty_wrap.cc

@ -50,7 +50,7 @@ class TTYWrap : StreamWrap {
HandleScope scope; HandleScope scope;
int fd = args[0]->Int32Value(); int fd = args[0]->Int32Value();
assert(fd >= 0); assert(fd >= 0);
return uv_is_tty(fd) ? v8::True() : v8::False(); return uv_guess_handle(fd) == UV_TTY ? v8::True() : v8::False();
} }
static Handle<Value> New(const Arguments& args) { static Handle<Value> New(const Arguments& args) {

Loading…
Cancel
Save