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

Commit 02b6f7c

Browse files
committed
fixup! dgram: make UDPWrap more reusable
1 parent 17e185f commit 02b6f7c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/udp_wrap.cc

+4
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
496496
ssize_t UDPWrap::Send(uv_buf_t* bufs_ptr,
497497
size_t count,
498498
const sockaddr* addr) {
499+
if (IsHandleClosing()) return UV_EBADF;
500+
499501
size_t msg_size = 0;
500502
for (size_t i = 0; i < count; i++)
501503
msg_size += bufs_ptr[i].len;
@@ -589,6 +591,7 @@ void UDPWrap::RecvStart(const FunctionCallbackInfo<Value>& args) {
589591
}
590592

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

608611
int UDPWrap::RecvStop() {
612+
if (IsHandleClosing()) return UV_EBADF;
609613
return uv_udp_recv_stop(&handle_);
610614
}
611615

0 commit comments

Comments
 (0)