Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Upgrade libuv to f20297f

  • Loading branch information...
ry committed Sep 23, 2011
1 parent 1e37efb commit 94bedc60f4ea429c9051422916014835374c51d5
@@ -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,
@@ -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.
@@ -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);

/*
@@ -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);

@@ -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,
@@ -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. */
@@ -600,8 +600,6 @@ static int uv_getaddrinfo_done(eio_req* req) {

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

freeaddrinfo(res);

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. */
int uv__socket(int domain, int type, int protocol) {
#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC)
@@ -19,6 +19,7 @@
*/

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

#include <assert.h>
#include <stdint.h>
@@ -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) {
@@ -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;

@@ -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);
}


@@ -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;
}


@@ -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;
}
@@ -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);
}


@@ -45,6 +45,7 @@ static void getaddrinfo_basic_cb(uv_getaddrinfo_t* handle,
ASSERT(handle == getaddrinfo_handle);
getaddrinfo_cbs++;
free(handle);
uv_freeaddrinfo(res);
}


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

free(data);
uv_freeaddrinfo(res);

getaddrinfo_cbs++;
}
@@ -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);

@@ -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) {

0 comments on commit 94bedc6

Please sign in to comment.
You can’t perform that action at this time.