Merge remote branch 'origin/master'
authorBert Belder <bertbelder@gmail.com>
Sun, 2 Jan 2011 21:57:32 +0000 (22:57 +0100)
committerBert Belder <bertbelder@gmail.com>
Sun, 2 Jan 2011 21:57:32 +0000 (22:57 +0100)
Conflicts:
src/node_net.cc
src/node_os.cc

1  2 
src/node.cc
src/node.js
src/node_net.cc
src/node_os.cc
src/platform_cygwin.cc
wscript

diff --cc src/node.cc
Simple merge
diff --cc src/node.js
Simple merge
diff --cc src/node_net.cc
@@@ -459,10 -372,7 +459,10 @@@ static Handle<Value> Connect(const Argu
    return Undefined();
  }
  
- #define ADDRESS_TO_JS(info, address_storage) \
 +
 +#ifdef __POSIX__
 +
+ #define ADDRESS_TO_JS(info, address_storage, addrlen) \
  do { \
    char ip[INET6_ADDRSTRLEN]; \
    int port; \
    } \
  } while (0)
  
- #define ADDRESS_TO_JS(info, address_storage) \
 +#else // __MINGW32__
 +
-   switch ((address_storage).ss_family) { \
-     case AF_INET6: \
-       a6 = (struct sockaddr_in6*)&(address_storage); \
-       inet_ntop(AF_INET6, &(a6->sin6_addr), ip, INET6_ADDRSTRLEN); \
-       port = ntohs(a6->sin6_port); \
-       (info)->Set(address_symbol, String::New(ip)); \
-       (info)->Set(port_symbol, Integer::New(port)); \
-       break; \
-     case AF_INET: \
-       a4 = (struct sockaddr_in*)&(address_storage); \
-       inet_ntop(AF_INET, &(a4->sin_addr), ip, INET6_ADDRSTRLEN); \
-       port = ntohs(a4->sin_port); \
-       (info)->Set(address_symbol, String::New(ip)); \
-       (info)->Set(port_symbol, Integer::New(port)); \
-       break; \
-     default: \
-       (info)->Set(address_symbol, String::Empty()); \
++#define ADDRESS_TO_JS(info, address_storage, addrlen) \
 +do { \
 +  char ip[INET6_ADDRSTRLEN]; \
 +  int port; \
 +  struct sockaddr_in *a4; \
 +  struct sockaddr_in6 *a6; \
++  if (addrlen == 0) { \
++    (info)->Set(address_symbol, String::Empty()); \
++  } else { \
++    switch ((address_storage).ss_family) { \
++      case AF_INET6: \
++        a6 = (struct sockaddr_in6*)&(address_storage); \
++        inet_ntop(AF_INET6, &(a6->sin6_addr), ip, INET6_ADDRSTRLEN); \
++        port = ntohs(a6->sin6_port); \
++        (info)->Set(address_symbol, String::New(ip)); \
++        (info)->Set(port_symbol, Integer::New(port)); \
++        break; \
++      case AF_INET: \
++        a4 = (struct sockaddr_in*)&(address_storage); \
++        inet_ntop(AF_INET, &(a4->sin_addr), ip, INET6_ADDRSTRLEN); \
++        port = ntohs(a4->sin_port); \
++        (info)->Set(address_symbol, String::New(ip)); \
++        (info)->Set(port_symbol, Integer::New(port)); \
++        break; \
++      default: \
++        (info)->Set(address_symbol, String::Empty()); \
++    } \
 +  } \
 +} while (0)
 +
 +#endif // __MINGW32__
 +
 +
 +#ifdef __POSIX__
  
  static Handle<Value> GetSockName(const Arguments& args) {
    HandleScope scope;
@@@ -614,26 -502,12 +636,27 @@@ static Handle<Value> Accept(const Argum
  
    if (peer_fd < 0) {
      if (errno == EAGAIN) return scope.Close(Null());
+     if (errno == ECONNABORTED) return scope.Close(Null());
      return ThrowException(ErrnoException(errno, "accept"));
    }
 +#else // __MINGW32__
 +  int peer_handle = accept(_get_osfhandle(fd), (struct sockaddr*) &address_storage, &len);
 +
 +  if (peer_handle == INVALID_SOCKET) {
 +    int wsaErrno = WSAGetLastError();
 +    if (wsaErrno == WSAEWOULDBLOCK) return scope.Close(Null());
 +    return ThrowException(ErrnoException(wsaErrno, "accept"));
 +  }
 +
 +  int peer_fd = _open_osfhandle(peer_handle, 0);
 +#endif // __MINGW32__
  
    if (!SetSockFlags(peer_fd)) {
 +#ifdef __POSIX__
      int fcntl_errno = errno;
 +#else // __MINGW32__
 +    int fcntl_errno = WSAGetLastError();
 +#endif // __MINGW32__
      close(peer_fd);
      return ThrowException(ErrnoException(fcntl_errno, "fcntl"));
    }
diff --cc src/node_os.cc
@@@ -3,14 -3,13 +3,18 @@@
  #include <node.h>
  #include <v8.h>
  
+ #include "platform.h"
  #include <errno.h>
 -#include <unistd.h>  // gethostname, sysconf
 -#include <sys/utsname.h>
+ #include <string.h>
  
- # include <unistd.h>  // gethostname
 +#ifdef __POSIX__
++# include <unistd.h>  // gethostname, sysconf
++# include <sys/utsname.h>
 +#else // __MINGW32__
 +# include <winsock2.h> // gethostname
 +#endif // __MINGW32__
 +
  namespace node {
  
  using namespace v8;
@@@ -39,4 -122,4 +131,4 @@@ void OS::Initialize(v8::Handle<v8::Obje
  
  }  // namespace node
  
--NODE_MODULE(node_os, node::OS::Initialize);
++NODE_MODULE(node_os, node::OS::Initialize);
Simple merge
diff --cc wscript
Simple merge