From: Gurusamy Sarathy Date: Sat, 17 May 2003 04:49:18 +0000 (+0000) Subject: avoid select() on windows destroying errno (used to typically X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1c8780751e85c3ece441fc8ecdff2f1dc99f9906;p=p5sagit%2Fp5-mst-13.2.git avoid select() on windows destroying errno (used to typically always sets it to EINVAL due to the way it maps the FD_SETs) p4raw-id: //depot/perl@19533 --- diff --git a/win32/win32sck.c b/win32/win32sck.c index cd537b3..d89c306 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -291,7 +291,7 @@ win32_select(int nfds, Perl_fd_set* rd, Perl_fd_set* wr, Perl_fd_set* ex, const int r; #ifdef USE_SOCKETS_AS_HANDLES Perl_fd_set dummy; - int i, fd; + int i, fd, save_errno; FD_SET nrd, nwr, nex, *prd, *pwr, *pex; /* winsock seems incapable of dealing with all three null fd_sets, @@ -333,7 +333,9 @@ win32_select(int nfds, Perl_fd_set* rd, Perl_fd_set* wr, Perl_fd_set* ex, const FD_SET(fd, &nex); } + errno = save_errno; SOCKET_TEST_ERROR(r = select(nfds, prd, pwr, pex, timeout)); + save_errno = errno; for (i = 0; i < nfds; i++) { fd = TO_SOCKET(i); @@ -344,6 +346,7 @@ win32_select(int nfds, Perl_fd_set* rd, Perl_fd_set* wr, Perl_fd_set* ex, const if (PERL_FD_ISSET(i,ex) && !FD_ISSET(fd, &nex)) PERL_FD_CLR(i,ex); } + errno = save_errno; #else SOCKET_TEST_ERROR(r = select(nfds, rd, wr, ex, timeout)); #endif