Fix dns on windows
This commit is contained in:
parent
3ec030535c
commit
61af4207da
10
lib/dns.js
10
lib/dns.js
@ -33,7 +33,13 @@ function updateTimer() {
|
|||||||
|
|
||||||
|
|
||||||
var channel = new dns.Channel({SOCK_STATE_CB: function(socket, read, write) {
|
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) {
|
if (socket in watchers) {
|
||||||
watcher = watchers[socket].watcher;
|
watcher = watchers[socket].watcher;
|
||||||
@ -56,7 +62,7 @@ var channel = new dns.Channel({SOCK_STATE_CB: function(socket, read, write) {
|
|||||||
delete activeWatchers[socket];
|
delete activeWatchers[socket];
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
watcher.set(socket, read == 1, write == 1);
|
watcher.set(fd, read == 1, write == 1);
|
||||||
watcher.start();
|
watcher.start();
|
||||||
activeWatchers[socket] = watcher;
|
activeWatchers[socket] = watcher;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
# include <io.h>
|
||||||
|
|
||||||
# include <platform_win32.h>
|
# include <platform_win32.h>
|
||||||
# include <platform_win32_winsock.h>
|
# include <platform_win32_winsock.h>
|
||||||
#endif
|
#endif
|
||||||
@ -138,6 +140,20 @@ static Handle<Value> GetLoadAvg(const Arguments& args) {
|
|||||||
return scope.Close(loads);
|
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) {
|
void OS::Initialize(v8::Handle<v8::Object> target) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
|
|
||||||
@ -149,6 +165,10 @@ void OS::Initialize(v8::Handle<v8::Object> target) {
|
|||||||
NODE_SET_METHOD(target, "getCPUs", GetCPUInfo);
|
NODE_SET_METHOD(target, "getCPUs", GetCPUInfo);
|
||||||
NODE_SET_METHOD(target, "getOSType", GetOSType);
|
NODE_SET_METHOD(target, "getOSType", GetOSType);
|
||||||
NODE_SET_METHOD(target, "getOSRelease", GetOSRelease);
|
NODE_SET_METHOD(target, "getOSRelease", GetOSRelease);
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
NODE_SET_METHOD(target, "openOSHandle", OpenOSHandle);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user