From feb976f456b018de0859804715eaaddfa573e0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Sat, 21 May 2016 00:01:48 +0200 Subject: [PATCH] udp: use libuv API to get file descriptor Refs: https://github.com/nodejs/node/pull/6838 PR-URL: https://github.com/nodejs/node/pull/6908 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/udp_wrap.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index baa8b888cf32d6..8c5090ddf74e2f 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -139,12 +139,14 @@ void UDPWrap::New(const FunctionCallbackInfo& args) { void UDPWrap::GetFD(Local, const PropertyCallbackInfo& args) { + int fd = -1; #if !defined(_WIN32) HandleScope scope(args.GetIsolate()); UDPWrap* wrap = Unwrap(args.Holder()); - int fd = (wrap == nullptr) ? -1 : wrap->handle_.io_watcher.fd; - args.GetReturnValue().Set(fd); + if (wrap != nullptr) + uv_fileno(reinterpret_cast(&wrap->handle_), &fd); #endif + args.GetReturnValue().Set(fd); }