Skip to content

Commit a1719a9

Browse files
saghulMyles Borins
authored and
Myles Borins
committed
udp: use libuv API to get file descriptor
Refs: #6838 PR-URL: #6908 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent b07c3a6 commit a1719a9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/udp_wrap.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,14 @@ void UDPWrap::New(const FunctionCallbackInfo<Value>& args) {
136136

137137

138138
void UDPWrap::GetFD(Local<String>, const PropertyCallbackInfo<Value>& args) {
139+
int fd = -1;
139140
#if !defined(_WIN32)
140141
HandleScope scope(args.GetIsolate());
141142
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder());
142-
int fd = (wrap == nullptr) ? -1 : wrap->handle_.io_watcher.fd;
143-
args.GetReturnValue().Set(fd);
143+
if (wrap != nullptr)
144+
uv_fileno(reinterpret_cast<uv_handle_t*>(&wrap->handle_), &fd);
144145
#endif
146+
args.GetReturnValue().Set(fd);
145147
}
146148

147149

0 commit comments

Comments
 (0)