Skip to content

Commit 3ef2eb2

Browse files
committed
udp: use libuv API to get file descriptor
Refs: #6838 PR-URL: #6908 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent ef9778c commit 3ef2eb2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/udp_wrap.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,14 @@ void UDPWrap::New(const FunctionCallbackInfo<Value>& args) {
139139

140140

141141
void UDPWrap::GetFD(Local<String>, const PropertyCallbackInfo<Value>& args) {
142+
int fd = -1;
142143
#if !defined(_WIN32)
143144
HandleScope scope(args.GetIsolate());
144145
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder());
145-
int fd = (wrap == nullptr) ? -1 : wrap->handle_.io_watcher.fd;
146-
args.GetReturnValue().Set(fd);
146+
if (wrap != nullptr)
147+
uv_fileno(reinterpret_cast<uv_handle_t*>(&wrap->handle_), &fd);
147148
#endif
149+
args.GetReturnValue().Set(fd);
148150
}
149151

150152

0 commit comments

Comments
 (0)