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 f20297f
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Sep 23, 2011
1 parent 1e37efb commit 94bedc6
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 28 deletions.
49 changes: 44 additions & 5 deletions deps/uv/README → deps/uv/README.md
@@ -1,10 +1,49 @@
This is the new networking 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.
# libuv

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/

= 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
makefiles or via GYP. GYP is a meta-build system which can generate MSVS,
Expand Down Expand Up @@ -38,7 +77,7 @@ Macintosh users run
xcodebuild -project uv.xcodeproj -configuration Release -target All


= Supported Platforms
## Supported Platforms

Microsoft Windows operating systems since Windows XP SP2. It can be built
with either Visual Studio or MinGW.
Expand Down
14 changes: 7 additions & 7 deletions deps/uv/include/uv.h
Expand Up @@ -612,11 +612,6 @@ struct uv_tty_s {
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);

/*
Expand All @@ -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
* descriptor. Usually this will be used during initialization to guess the
* 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);

Expand Down Expand Up @@ -807,8 +803,10 @@ struct uv_getaddrinfo_s {
*
* 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.
* Input arguments may be released after return from this call. Callback
* must not call freeaddrinfo.
* Input arguments may be released after return from this call.
*
* uv_freeaddrinfo() must be called after completion to free the addrinfo
* structure.
*/
int uv_getaddrinfo(uv_loop_t*,
uv_getaddrinfo_t* handle,
Expand All @@ -817,6 +815,8 @@ struct uv_getaddrinfo_s {
const char* service,
const struct addrinfo* hints);

void uv_freeaddrinfo(struct addrinfo* ai);

/* uv_spawn() options */
typedef struct uv_process_options_s {
uv_exit_cb exit_cb; /* Called after the process exits. */
Expand Down
7 changes: 5 additions & 2 deletions deps/uv/src/unix/core.c
Expand Up @@ -600,8 +600,6 @@ static int uv_getaddrinfo_done(eio_req* req) {

handle->cb(handle, handle->retcode, res);

freeaddrinfo(res);

return 0;
}

Expand Down Expand Up @@ -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. */
int uv__socket(int domain, int type, int protocol) {
#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC)
Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/unix/darwin.c
Expand Up @@ -19,6 +19,7 @@
*/

#include "uv.h"
#include "internal.h"

#include <assert.h>
#include <stdint.h>
Expand Down
6 changes: 1 addition & 5 deletions deps/uv/src/unix/tty.c
Expand Up @@ -26,6 +26,7 @@
#include <unistd.h>
#include <termios.h>
#include <errno.h>
#include <sys/ioctl.h>


int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd) {
Expand Down Expand Up @@ -69,11 +70,6 @@ int uv_tty_set_mode(uv_tty_t* tty, int mode) {
}


int uv_is_tty(uv_file file) {
return isatty(file);
}


int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) {
struct winsize ws;

Expand Down
9 changes: 7 additions & 2 deletions deps/uv/src/win/getaddrinfo.c
Expand Up @@ -216,12 +216,17 @@ void uv_process_getaddrinfo_req(uv_loop_t* loop, uv_getaddrinfo_t* handle,
/* finally do callback with converted result */
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 */
if (alloc_ptr != NULL) {
free(alloc_ptr);
}

uv_unref(loop);
}


Expand Down
11 changes: 8 additions & 3 deletions deps/uv/src/win/tty.c
Expand Up @@ -38,9 +38,6 @@ int uv_tty_set_mode(uv_tty_t* tty, int mode) {


int uv_is_tty(uv_file file) {
DWORD result;
int r = GetConsoleMode((HANDLE)_get_osfhandle(file), &result);
return r ? 1 : 0;
}


Expand All @@ -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) {
DWORD result;
int r = GetConsoleMode((HANDLE)_get_osfhandle(file), &result);

if (r) {
return UV_TTY;
}

assert(0 && "implement me");

return UV_UNKNOWN_HANDLE;
}
2 changes: 2 additions & 0 deletions deps/uv/test/benchmark-getaddrinfo.c
Expand Up @@ -52,6 +52,8 @@ static void getaddrinfo_cb(uv_getaddrinfo_t* handle, int status,
if (calls_initiated < TOTAL_CALLS) {
getaddrinfo_initiate(handle);
}

uv_freeaddrinfo(res);
}


Expand Down
2 changes: 2 additions & 0 deletions deps/uv/test/test-getaddrinfo.c
Expand Up @@ -45,6 +45,7 @@ static void getaddrinfo_basic_cb(uv_getaddrinfo_t* handle,
ASSERT(handle == getaddrinfo_handle);
getaddrinfo_cbs++;
free(handle);
uv_freeaddrinfo(res);
}


Expand All @@ -65,6 +66,7 @@ static void getaddrinfo_cuncurrent_cb(uv_getaddrinfo_t* handle,
ASSERT (i < CONCURRENT_COUNT);

free(data);
uv_freeaddrinfo(res);

getaddrinfo_cbs++;
}
Expand Down
4 changes: 1 addition & 3 deletions deps/uv/test/test-tty.c
Expand Up @@ -31,13 +31,11 @@ TEST_IMPL(tty) {
* Not necessarally a problem if this assert goes off. E.G you are piping
* 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);
ASSERT(r == 0);

ASSERT(UV_TTY == uv_guess_handle(0));

r = uv_tty_get_winsize(&tty, &width, &height);
ASSERT(r == 0);

Expand Down
2 changes: 1 addition & 1 deletion src/tty_wrap.cc
Expand Up @@ -50,7 +50,7 @@ class TTYWrap : StreamWrap {
HandleScope scope;
int fd = args[0]->Int32Value();
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) {
Expand Down

0 comments on commit 94bedc6

Please sign in to comment.