diff options
author | Bert Belder <bertbelder@gmail.com> | 2011-02-07 23:39:36 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-02-07 15:30:17 -0800 |
commit | 61af4207dae4e43aa16f17c77b34391bb1e3da5b (patch) | |
tree | d69329e43a4714120ba8d3ae6edd3f2cd2997770 | |
parent | 3ec030535c5a289cefbca7881da2554ef276253d (diff) | |
download | nodejs-61af4207dae4e43aa16f17c77b34391bb1e3da5b.tar.gz nodejs-61af4207dae4e43aa16f17c77b34391bb1e3da5b.tar.bz2 nodejs-61af4207dae4e43aa16f17c77b34391bb1e3da5b.zip |
Fix dns on windows
-rw-r--r-- | lib/dns.js | 10 | ||||
-rw-r--r-- | src/node_os.cc | 20 |
2 files changed, 28 insertions, 2 deletions
diff --git a/lib/dns.js b/lib/dns.js index 8d7eef2a6..516c7c20c 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -33,7 +33,13 @@ function updateTimer() { var channel = new dns.Channel({SOCK_STATE_CB: function(socket, read, write) { - var watcher; + var watcher, fd; + + if (process.platform == 'win32') { + fd = process.binding('os').openOSHandle(socket); + } else { + fd = socket; + } if (socket in watchers) { watcher = watchers[socket].watcher; @@ -56,7 +62,7 @@ var channel = new dns.Channel({SOCK_STATE_CB: function(socket, read, write) { delete activeWatchers[socket]; return; } else { - watcher.set(socket, read == 1, write == 1); + watcher.set(fd, read == 1, write == 1); watcher.start(); activeWatchers[socket] = watcher; } diff --git a/src/node_os.cc b/src/node_os.cc index 8c85d1b0c..643eb69ff 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -9,6 +9,8 @@ #include <string.h> #ifdef __MINGW32__ +# include <io.h> + # include <platform_win32.h> # include <platform_win32_winsock.h> #endif @@ -138,6 +140,20 @@ static Handle<Value> GetLoadAvg(const Arguments& args) { return scope.Close(loads); } +#ifdef __MINGW32__ +static Handle<Value> OpenOSHandle(const Arguments& args) { + HandleScope scope; + + intptr_t handle = args[0]->IntegerValue(); + + int fd = _open_osfhandle(handle, 0); + if (fd < 0) + return ThrowException(ErrnoException(errno, "_open_osfhandle")); + + return scope.Close(Integer::New(fd)); +} +#endif // __MINGW32__ + void OS::Initialize(v8::Handle<v8::Object> target) { HandleScope scope; @@ -149,6 +165,10 @@ void OS::Initialize(v8::Handle<v8::Object> target) { NODE_SET_METHOD(target, "getCPUs", GetCPUInfo); NODE_SET_METHOD(target, "getOSType", GetOSType); NODE_SET_METHOD(target, "getOSRelease", GetOSRelease); + +#ifdef __MINGW32__ + NODE_SET_METHOD(target, "openOSHandle", OpenOSHandle); +#endif } |