X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=win32%2Fwin32sck.c;h=271360584026764d56237d5d89a62c2db5eb6cb0;hb=9cc6feabb930fb7cac992ab0a2febf2fb1986667;hp=74af5d7756436d0f306cc588286933f4a5c0d738;hpb=58a50f6288bdd18f3f469352f83c5e7ade50ee7a;p=p5sagit%2Fp5-mst-13.2.git diff --git a/win32/win32sck.c b/win32/win32sck.c index 74af5d7..2713605 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -13,10 +13,6 @@ #define WIN32_LEAN_AND_MEAN #ifdef __GNUC__ #define Win32_Winsock -# ifdef __cplusplus -#undef __attribute__ /* seems broken in 2.8.0 */ -#define __attribute__(p) -# endif #endif #include #include "EXTERN.h" @@ -291,8 +287,15 @@ int win32_recvfrom(SOCKET s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen) { int r; + int frombufsize = *fromlen; SOCKET_TEST_ERROR(r = recvfrom(TO_SOCKET(s), buf, len, flags, from, fromlen)); + /* Winsock's recvfrom() only returns a valid 'from' when the socket + * is connectionless. Perl expects a valid 'from' for all types + * of sockets, so go the extra mile. + */ + if (r != SOCKET_ERROR && frombufsize == *fromlen) + (void)win32_getpeername(s, from, fromlen); return r; } @@ -310,8 +313,11 @@ win32_select(int nfds, Perl_fd_set* rd, Perl_fd_set* wr, Perl_fd_set* ex, const * 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 */ + if (timeout) + Sleep(timeout->tv_sec * 1000 + + timeout->tv_usec / 1000); /* do the best we can */ + else + Sleep(UINT_MAX); return 0; } StartSockets();