summaryrefslogtreecommitdiff
path: root/win32/win32sck.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2003-05-17 04:49:18 +0000
committerGurusamy Sarathy <gsar@cpan.org>2003-05-17 04:49:18 +0000
commit1c8780751e85c3ece441fc8ecdff2f1dc99f9906 (patch)
tree18ce8d008e4547194a9c5bb07841f843138c544c /win32/win32sck.c
parent2cc1b180444ab1e2ac675ff3e9f78a123bc70c80 (diff)
downloadperl-1c8780751e85c3ece441fc8ecdff2f1dc99f9906.tar.gz
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
Diffstat (limited to 'win32/win32sck.c')
-rw-r--r--win32/win32sck.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/win32/win32sck.c b/win32/win32sck.c
index cd537b3e38..d89c306cbb 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