Skip to content

Commit

Permalink
Call select's 4th arg's magic
Browse files Browse the repository at this point in the history
[perl #120102] CORE::select ignoring timeout var's magic

Patch by Eric, with tested added by davem.
  • Loading branch information
ikegami authored and iabyn committed Oct 18, 2013
1 parent a7ed8fa commit 90eaaf0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pp_sys.c
Expand Up @@ -1159,8 +1159,9 @@ PP(pp_sselect)
# endif

sv = SP[4];
SvGETMAGIC(sv);
if (SvOK(sv)) {
value = SvNV(sv);
value = SvNV_nomg(sv);
if (value < 0.0)
value = 0.0;
timebuf.tv_sec = (long)value;
Expand Down
19 changes: 18 additions & 1 deletion t/op/sselect.t
Expand Up @@ -9,7 +9,7 @@ BEGIN {

require 'test.pl';

plan (14);
plan (15);

my $blank = "";
eval {select undef, $blank, $blank, 0};
Expand Down Expand Up @@ -74,3 +74,20 @@ $t1 = time;
$diff = $t1-$t0;
ok($diff >= $sleep-$under, "select(\$e,u,u,\$sleep): at least $sleep seconds have passed");
note("diff=$diff under=$under");

# [perl #120102] CORE::select ignoring timeout var's magic

{
package RT120102;

my $count = 0;

sub TIESCALAR { bless [] }
sub FETCH { $count++; 0.1 }

my $sleep;

tie $sleep, 'RT120102';
select (undef, undef, undef, $sleep);
::is($count, 1, 'RT120102');
}

0 comments on commit 90eaaf0

Please sign in to comment.