diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-05-17 07:13:29 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-05-22 16:14:24 +0200 |
commit | 039fac633eaf081a96bb1ed8bc7307d03dcbe9d9 (patch) | |
tree | b24085e8aab84e09ed8fd7d311cd360dbfd6259e /deps/uv/src/unix/loop.c | |
parent | a608f65b2454a83f08a60ba24088a672097540f5 (diff) | |
download | android-node-v8-039fac633eaf081a96bb1ed8bc7307d03dcbe9d9.tar.gz android-node-v8-039fac633eaf081a96bb1ed8bc7307d03dcbe9d9.tar.bz2 android-node-v8-039fac633eaf081a96bb1ed8bc7307d03dcbe9d9.zip |
deps: upgrade libuv to a478847
The event loop's reference counting scheme in this version of libuv has changed.
Update the libuv bindings to reflect that fact.
Diffstat (limited to 'deps/uv/src/unix/loop.c')
-rw-r--r-- | deps/uv/src/unix/loop.c | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/deps/uv/src/unix/loop.c b/deps/uv/src/unix/loop.c index 5580aba3fe..aca2a889fb 100644 --- a/deps/uv/src/unix/loop.c +++ b/deps/uv/src/unix/loop.c @@ -33,15 +33,31 @@ int uv__loop_init(uv_loop_t* loop, int default_loop) { #else int flags = EVFLAG_AUTO; #endif + + memset(loop, 0, sizeof(*loop)); + +#ifndef UV_LEAN_AND_MEAN + ngx_queue_init(&loop->active_handles); + ngx_queue_init(&loop->active_reqs); +#endif + RB_INIT(&loop->uv_ares_handles_); - loop->endgame_handles = NULL; + ngx_queue_init(&loop->idle_handles); + ngx_queue_init(&loop->check_handles); + ngx_queue_init(&loop->prepare_handles); + loop->pending_handles = NULL; + loop->channel = NULL; loop->ev = (default_loop ? ev_default_loop : ev_loop_new)(flags); ev_set_userdata(loop->ev, loop); eio_channel_init(&loop->uv_eio_channel, loop); + #if __linux__ RB_INIT(&loop->inotify_watchers); loop->inotify_fd = -1; #endif +#if HAVE_PORTS_FS + loop->fs_fd = -1; +#endif return 0; } @@ -55,4 +71,45 @@ void uv__loop_delete(uv_loop_t* loop) { close(loop->inotify_fd); loop->inotify_fd = -1; #endif +#if HAVE_PORTS_FS + if (loop->fs_fd != -1) + close(loop->fs_fd); +#endif } + + +#define X(name, type) \ + int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \ + uv__handle_init(loop, (uv_handle_t*)handle, type); \ + loop->counters.name##_init++; \ + handle->name##_cb = NULL; \ + return 0; \ + } \ + int uv_##name##_start(uv_##name##_t* handle, uv_##name##_cb cb) { \ + if (uv__is_active(handle)) return 0; \ + ngx_queue_insert_head(&handle->loop->name##_handles, &handle->queue); \ + handle->name##_cb = cb; \ + uv__handle_start(handle); \ + return 0; \ + } \ + int uv_##name##_stop(uv_##name##_t* handle) { \ + if (!uv__is_active(handle)) return 0; \ + ngx_queue_remove(&handle->queue); \ + uv__handle_stop(handle); \ + return 0; \ + } \ + void uv__run_##name(uv_loop_t* loop) { \ + uv_##name##_t* h; \ + ngx_queue_t* q; \ + ngx_queue_foreach(q, &loop->name##_handles) { \ + h = ngx_queue_data(q, uv_##name##_t, queue); \ + if (h->name##_cb) h->name##_cb(h, 0); \ + } \ + } \ + void uv__##name##_close(uv_##name##_t* handle) { \ + uv_##name##_stop(handle); \ + } +X(idle, UV_IDLE) +X(check, UV_CHECK) +X(prepare, UV_PREPARE) +#undef X |