Skip to content

Commit

Permalink
Calling uv_poll_start() on a handle that is already active is fine. D…
Browse files Browse the repository at this point in the history
…oing so will update the events mask that is being watched for.
  • Loading branch information
splitice committed Apr 30, 2024
1 parent 83904ab commit 3d8c814
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ class Socket extends EventEmitter {
this.wrap.pause (this.recvPaused, this.sendPaused);
return this;
}

pause (recv, send) {
this.recvPaused = recv;
this.sendPaused = send;
this.wrap.pause (this.recvPaused, this.sendPaused);
return this;
}

send (buffer, offset, length, address,
beforeCallback, afterCallback) {
Expand Down
3 changes: 2 additions & 1 deletion src/raw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,10 @@ NAN_METHOD(SocketWrap::Pause) {
| (pause_send ? 0 : UV_WRITABLE);

if (! socket->deconstructing_ && socket->poll_initialised_) {
uv_poll_stop (socket->poll_watcher_);
if (events)
uv_poll_start (socket->poll_watcher_, events, IoEvent);
else
uv_poll_stop (socket->poll_watcher_);
}

info.GetReturnValue().Set(info.This());
Expand Down

0 comments on commit 3d8c814

Please sign in to comment.