Skip to content

Commit

Permalink
Merge pull request #310 from deepcoldy/master
Browse files Browse the repository at this point in the history
fix: Cannot start the zookeeper client in a Node.js Worker thread
  • Loading branch information
DavidVujic authored Apr 16, 2022
2 parents 98b97c4 + 24dcfc4 commit c2d6437
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/node-zk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class ZooKeeper: public Nan::ObjectWrap {
return;
}

last_activity = uv_now(uv_default_loop());
last_activity = uv_now(Nan::GetCurrentEventLoop());

#ifdef WIN32
SOCKET oldFd = fd;
Expand Down Expand Up @@ -334,9 +334,9 @@ class ZooKeeper: public Nan::ObjectWrap {

zk_io->data = this;
#ifdef WIN32
uv_poll_init_socket(uv_default_loop(), zk_io, fd);
uv_poll_init_socket(Nan::GetCurrentEventLoop(), zk_io, fd);
#else
uv_poll_init(uv_default_loop(), zk_io, fd);
uv_poll_init(Nan::GetCurrentEventLoop(), zk_io, fd);
#endif
}

Expand Down Expand Up @@ -387,7 +387,7 @@ class ZooKeeper: public Nan::ObjectWrap {
LOG_DEBUG("zk_timer_cb fired");

ZooKeeper *zk = static_cast<ZooKeeper*>(w->data);
int64_t now = uv_now(uv_default_loop());
int64_t now = uv_now(Nan::GetCurrentEventLoop());
int64_t timeout = zk->last_activity + zk->tv.tv_sec * 1000 + zk->tv.tv_usec / 1000.;

// if last_activity + tv.tv_sec is older than now, we did time out
Expand Down Expand Up @@ -421,7 +421,7 @@ class ZooKeeper: public Nan::ObjectWrap {
}
Ref();

uv_timer_init(uv_default_loop(), &zk_timer);
uv_timer_init(Nan::GetCurrentEventLoop(), &zk_timer);
zk_timer.data = this;

noResponseCounter = 0;
Expand Down

0 comments on commit c2d6437

Please sign in to comment.