Subject: | mmc_lock_page() clobbers high-resolution alarm |
When a high-resolution alarm (ualarm or setitimer) is set outside of
Cache::FastMmap, the current implementation of mmc_lock_page() clobbers
its value. I'm using Cache::FastMmap in an environment that needs
sub-second timeout controls, so this is a problem for me.
Here's the test case:
#!/usr/bin/env perl
use strict;
use warnings;
use Cache::FastMmap ();
use File::Temp ();
use Time::HiRes ();
use Test::More qw(no_plan);
my $share_file = File::Temp::tmpnam();
my $c = new Cache::FastMmap(
init_file => 1,
share_file => $share_file,
page_size => 65536,
num_pages => 89,
raw_values => 1,
compress => 0,
enable_stats => 0,
expire_time => 0,
unlink_on_exit => 0,
empty_on_exit => 0,
);
$c->set('foo', 'bar');
my $now = Time::HiRes::time();
eval {
local $SIG{ALRM} = sub {die};
Time::HiRes::alarm(0.1);
$c->get('foo');
sleep(60);
Time::HiRes::alarm(0);
};
ok((Time::HiRes::time() - $now) < 1, "should have alarmed my way out of
the eval in < 1 second");
unlink $share_file;