Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 6e1eac7

Browse files
saghulindutny
authored andcommitted
src: use new loop API
uv_loop_new and uv_loop_delete are considered deprecated now.
1 parent 269de79 commit 6e1eac7

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/node_watchdog.cc

+9-3
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ using v8::V8;
2929

3030

3131
Watchdog::Watchdog(uint64_t ms) : destroyed_(false) {
32-
loop_ = uv_loop_new();
32+
int rc;
33+
loop_ = new uv_loop_t;
3334
CHECK(loop_);
35+
rc = uv_loop_init(loop_);
36+
CHECK_EQ(0, rc);
3437

35-
int rc = uv_async_init(loop_, &async_, &Watchdog::Async);
38+
rc = uv_async_init(loop_, &async_, &Watchdog::Async);
3639
CHECK_EQ(0, rc);
3740

3841
rc = uv_timer_init(loop_, &timer_);
@@ -69,7 +72,10 @@ void Watchdog::Destroy() {
6972
// UV_RUN_DEFAULT so that libuv has a chance to clean up.
7073
uv_run(loop_, UV_RUN_DEFAULT);
7174

72-
uv_loop_delete(loop_);
75+
int rc = uv_loop_close(loop_);
76+
CHECK_EQ(0, rc);
77+
delete loop_;
78+
loop_ = NULL;
7379

7480
destroyed_ = true;
7581
}

src/spawn_sync.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "spawn_sync.h"
2323
#include "env-inl.h"
2424
#include "string_bytes.h"
25+
#include "util.h"
2526

2627
#include <string.h>
2728
#include <stdlib.h>
@@ -450,9 +451,10 @@ void SyncProcessRunner::TryInitializeAndRunLoop(Local<Value> options) {
450451
assert(lifecycle_ == kUninitialized);
451452
lifecycle_ = kInitialized;
452453

453-
uv_loop_ = uv_loop_new();
454+
uv_loop_ = new uv_loop_t;
454455
if (uv_loop_ == NULL)
455456
return SetError(UV_ENOMEM);
457+
CHECK_EQ(uv_loop_init(uv_loop_), 0);
456458

457459
r = ParseOptions(options);
458460
if (r < 0)
@@ -515,7 +517,9 @@ void SyncProcessRunner::CloseHandlesAndDeleteLoop() {
515517
if (r < 0)
516518
abort();
517519

518-
uv_loop_delete(uv_loop_);
520+
CHECK_EQ(uv_loop_close(uv_loop_), 0);
521+
delete uv_loop_;
522+
uv_loop_ = NULL;
519523

520524
} else {
521525
// If the loop doesn't exist, neither should any pipes or timers.

0 commit comments

Comments
 (0)