Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
fixup! dgram: make UDPWrap more reusable
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Oct 11, 2019
1 parent f652f65 commit a915058
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/udp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
ssize_t UDPWrap::Send(uv_buf_t* bufs_ptr,
size_t count,
const sockaddr* addr) {
if (IsHandleClosing()) return UV_EBADF;

size_t msg_size = 0;
for (size_t i = 0; i < count; i++)
msg_size += bufs_ptr[i].len;
Expand Down Expand Up @@ -589,6 +591,7 @@ void UDPWrap::RecvStart(const FunctionCallbackInfo<Value>& args) {
}

int UDPWrap::RecvStart() {
if (IsHandleClosing()) return UV_EBADF;
int err = uv_udp_recv_start(&handle_, OnAlloc, OnRecv);
// UV_EALREADY means that the socket is already bound but that's okay
if (err == UV_EALREADY)
Expand All @@ -606,6 +609,7 @@ void UDPWrap::RecvStop(const FunctionCallbackInfo<Value>& args) {
}

int UDPWrap::RecvStop() {
if (IsHandleClosing()) return UV_EBADF;
return uv_udp_recv_stop(&handle_);
}

Expand Down

0 comments on commit a915058

Please sign in to comment.