require 'test.pl';
-plan (9);
+plan (11);
my $blank = "";
eval {select undef, $blank, $blank, 0};
like ($@, qr/^Modification of a read-only value attempted/);
eval {select $blank, $blank, "a", 0};
like ($@, qr/^Modification of a read-only value attempted/);
+
+my $sleep = 3;
+my $t = time;
+select(undef, undef, undef, $sleep);
+ok(time-$t >= $sleep, "$sleep seconds have passed");
+
+my $empty = "";
+vec($empty,0,1) = 0;
+$t = time;
+select($empty, undef, undef, $sleep);
+ok(time-$t >= $sleep, "$sleep seconds have passed");
#ifdef USE_SOCKETS_AS_HANDLES
int i, fd, save_errno = errno;
FD_SET nrd, nwr, nex;
+ bool just_sleep = TRUE;
- /* winsock seems incapable of dealing with all three null fd_sets,
- * so do the (millisecond) sleep as a special case
- */
- if (!(rd || wr || ex)) {
- if (timeout)
- Sleep(timeout->tv_sec * 1000 +
- timeout->tv_usec / 1000); /* do the best we can */
- else
- Sleep(UINT_MAX);
- return 0;
- }
StartSockets();
FD_ZERO(&nrd);
if (rd && PERL_FD_ISSET(i,rd)) {
fd = TO_SOCKET(i);
FD_SET((unsigned)fd, &nrd);
+ just_sleep = FALSE;
}
if (wr && PERL_FD_ISSET(i,wr)) {
fd = TO_SOCKET(i);
FD_SET((unsigned)fd, &nwr);
+ just_sleep = FALSE;
}
if (ex && PERL_FD_ISSET(i,ex)) {
fd = TO_SOCKET(i);
FD_SET((unsigned)fd, &nex);
+ just_sleep = FALSE;
}
}
+ /* winsock seems incapable of dealing with all three fd_sets being empty,
+ * so do the (millisecond) sleep as a special case
+ */
+ if (just_sleep) {
+ if (timeout)
+ Sleep(timeout->tv_sec * 1000 +
+ timeout->tv_usec / 1000); /* do the best we can */
+ else
+ Sleep(UINT_MAX);
+ return 0;
+ }
+
errno = save_errno;
SOCKET_TEST_ERROR(r = select(nfds, &nrd, &nwr, &nex, timeout));
save_errno = errno;