Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

testing bailing out after a while so it doesn't lock stuff up completely

  • Loading branch information...
commit afdc55d5e9cecfb2d918b91ce4687259f7fc7235 1 parent e52bdce
Scott Walters authored
Showing with 5 additions and 7 deletions.
  1. +5 −7 lib/CHI/Driver/Ping.pm
12 lib/CHI/Driver/Ping.pm
View
@@ -157,15 +157,18 @@ sub store {
sub fetch {
+ local $SIG{USR1} = sub { use Carp; Carp::cluck "USR1"; };
+
my $self = shift;
my $key = shift;
my $delete_mode = shift;
my $ret = 0;
- my $elapsed_time = 0;
fcntl($self->fh, F_SETFL, fcntl($self->fh, F_GETFL, 0) | O_NONBLOCK) or die "fcntl: $!";
+ my $start_time = Time::HiRes::time;
+# warn "start_time $start_time";
my $return_value;
while(1) {
@@ -174,11 +177,7 @@ sub fetch {
my $from_seq = -1;
my $from_saddr = recv($self->fh, $recv_msg, 1500, ICMP_FLAGS); # sockaddr_in of sender
if( $! == Errno::EAGAIN ) {
- if( $elapsed_time > 1 ) {
- return; # tired of repeating packets, not in the cache, fell out of the cache, or we've stopped caring
- }
Time::HiRes::sleep(0.1);
- $elapsed_time += 0.1;
next;
}
my $from_port; # Port packet was sent from
@@ -200,9 +199,8 @@ sub fetch {
# return ($key, $value); # XXXX
}
}
+ return if Time::HiRes::time - $start_time > 2; # <------ here is also where we exit, in failure
}
- # return $return_value;
-
}
sub checksum {
Please sign in to comment.
Something went wrong with that request. Please try again.