diff --git a/src/node_watchdog.cc b/src/node_watchdog.cc index cec9aa52c9d..dd62dd7432f 100644 --- a/src/node_watchdog.cc +++ b/src/node_watchdog.cc @@ -29,10 +29,13 @@ using v8::V8; Watchdog::Watchdog(uint64_t ms) : destroyed_(false) { - loop_ = uv_loop_new(); + int rc; + loop_ = new uv_loop_t; CHECK(loop_); + rc = uv_loop_init(loop_); + CHECK_EQ(0, rc); - int rc = uv_async_init(loop_, &async_, &Watchdog::Async); + rc = uv_async_init(loop_, &async_, &Watchdog::Async); CHECK_EQ(0, rc); rc = uv_timer_init(loop_, &timer_); @@ -69,7 +72,10 @@ void Watchdog::Destroy() { // UV_RUN_DEFAULT so that libuv has a chance to clean up. uv_run(loop_, UV_RUN_DEFAULT); - uv_loop_delete(loop_); + int rc = uv_loop_close(loop_); + CHECK_EQ(0, rc); + delete loop_; + loop_ = NULL; destroyed_ = true; } diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index 4876422bda1..9b67a602c3e 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -22,6 +22,7 @@ #include "spawn_sync.h" #include "env-inl.h" #include "string_bytes.h" +#include "util.h" #include #include @@ -450,9 +451,10 @@ void SyncProcessRunner::TryInitializeAndRunLoop(Local options) { assert(lifecycle_ == kUninitialized); lifecycle_ = kInitialized; - uv_loop_ = uv_loop_new(); + uv_loop_ = new uv_loop_t; if (uv_loop_ == NULL) return SetError(UV_ENOMEM); + CHECK_EQ(uv_loop_init(uv_loop_), 0); r = ParseOptions(options); if (r < 0) @@ -515,7 +517,9 @@ void SyncProcessRunner::CloseHandlesAndDeleteLoop() { if (r < 0) abort(); - uv_loop_delete(uv_loop_); + CHECK_EQ(uv_loop_close(uv_loop_), 0); + delete uv_loop_; + uv_loop_ = NULL; } else { // If the loop doesn't exist, neither should any pipes or timers.