[asperl] added AS patch#10
[p5sagit/p5-mst-13.2.git] / win32 / win32sck.c
index 5ac2ef6..5c2b73f 100644 (file)
 #include <windows.h>
 #include "EXTERN.h"
 #include "perl.h"
+
+#if defined(PERL_OBJECT)
+#define NO_XSLOCKS
+extern CPerlObj* pPerl;
+#include "XSUB.h"
+#endif
+
 #include <sys/socket.h>
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -269,6 +276,15 @@ win32_select(int nfds, Perl_fd_set* rd, Perl_fd_set* wr, Perl_fd_set* ex, const
     int i, fd, bit, offset;
     FD_SET nrd, nwr, nex, *prd, *pwr, *pex;
 
+    /* winsock seems incapable of dealing with all three null fd_sets,
+     * so do the (millisecond) sleep as a special case
+     */
+    if (!(rd || wr || ex)) {
+       Sleep(timeout->tv_sec  * 1000 +
+             timeout->tv_usec / 1000);         /* do the best we can */
+       return 0;
+    }
+    StartSockets();
     PERL_FD_ZERO(&dummy);
     if (!rd)
        rd = &dummy, prd = NULL;
@@ -604,7 +620,7 @@ win32_savecopyservent(struct servent*d, struct servent*s, const char *proto)
        d->s_proto = s->s_proto;
     else
 #endif
-       if (proto && strlen(proto))
+    if (proto && strlen(proto))
        d->s_proto = (char *)proto;
     else
        d->s_proto = "tcp";