Test script for DynaLoader
[p5sagit/p5-mst-13.2.git] / win32 / win32sck.c
index 0e2be30..2795104 100644 (file)
@@ -125,7 +125,7 @@ my_fdopen(int fd, char *mode)
     /*
      * If we get here, then fd is actually a socket.
      */
-    Newz(1310, fp, 1, FILE);   /* XXX leak, good thing this code isn't used */
+    Newxz(fp, 1, FILE);        /* XXX leak, good thing this code isn't used */
     if(fp == NULL) {
        errno = ENOMEM;
        return NULL;
@@ -312,11 +312,11 @@ win32_select(int nfds, Perl_fd_set* rd, Perl_fd_set* wr, Perl_fd_set* ex, const
     for (i = 0; i < nfds; i++) {
        fd = TO_SOCKET(i);
        if (PERL_FD_ISSET(i,rd))
-           FD_SET(fd, &nrd);
+           FD_SET((unsigned)fd, &nrd);
        if (PERL_FD_ISSET(i,wr))
-           FD_SET(fd, &nwr);
+           FD_SET((unsigned)fd, &nwr);
        if (PERL_FD_ISSET(i,ex))
-           FD_SET(fd, &nex);
+           FD_SET((unsigned)fd, &nex);
     }
 
     errno = save_errno;
@@ -398,17 +398,22 @@ convert_proto_info_w2a(WSAPROTOCOL_INFOW *in, WSAPROTOCOL_INFOA *out)
 SOCKET
 open_ifs_socket(int af, int type, int protocol)
 {
+    dTHX;
+    char *s;
     unsigned long proto_buffers_len = 0;
     int error_code;
     SOCKET out = INVALID_SOCKET;
 
+    if ((s = PerlEnv_getenv("PERL_ALLOW_NON_IFS_LSP")) && atoi(s))
+        return WSASocket(af, type, protocol, NULL, 0, 0);
+
     if (WSCEnumProtocols(NULL, NULL, &proto_buffers_len, &error_code) == SOCKET_ERROR
         && error_code == WSAENOBUFS)
     {
        WSAPROTOCOL_INFOW *proto_buffers;
         int protocols_available = 0;       
  
-        New(1, proto_buffers, proto_buffers_len / sizeof(WSAPROTOCOL_INFOW),
+        Newx(proto_buffers, proto_buffers_len / sizeof(WSAPROTOCOL_INFOW),
             WSAPROTOCOL_INFOW);
 
         if ((protocols_available = WSCEnumProtocols(NULL, proto_buffers, 
@@ -421,7 +426,8 @@ open_ifs_socket(int af, int type, int protocol)
 
                 if ((af != AF_UNSPEC && af != proto_buffers[i].iAddressFamily)
                     || (type != proto_buffers[i].iSocketType)
-                    || (protocol != 0 && protocol != proto_buffers[i].iProtocol))
+                    || (protocol != 0 && proto_buffers[i].iProtocol != 0 &&
+                        protocol != proto_buffers[i].iProtocol))
                     continue;
 
                 if ((proto_buffers[i].dwServiceFlags1 & XP1_IFS_HANDLES) == 0)