summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0c4641d)
This can be relevant info do differentiate if an undef return value
happened due to the closure returning it or if it happened due to a
timeout.
While for quite a few cases this could be handled by a
variable captured by the passed closure code reference, acting as
messenger, that might often require needless wrapping.
Also run_fork_with_timeout warned errors of execution, but any such
error handling for an actual timeout is better handled at the call
site, as a context-less "got timeout" at STDERR or journal is really
not helpful.
I checked all call sites of both, run_fork_with_timeout and
run_with_timeout most do not use the result at all, and the ones that
do are in scalar context.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
my $prev_alarm = alarm 0; # suspend outer alarm early
my $sigcount = 0;
my $prev_alarm = alarm 0; # suspend outer alarm early
my $sigcount = 0;
- local $SIG{ALRM} = sub { $sigcount++; die "got timeout\n"; };
+ local $SIG{ALRM} = sub { $sigcount++; $got_timeout = 1; die "got timeout\n"; };
local $SIG{PIPE} = sub { $sigcount++; die "broken pipe\n" };
local $SIG{__DIE__}; # see SA bug 4631
local $SIG{PIPE} = sub { $sigcount++; die "broken pipe\n" };
local $SIG{__DIE__}; # see SA bug 4631
# this shouldn't happen anymore?
die "unknown error" if $sigcount && !$err; # seems to happen sometimes
# this shouldn't happen anymore?
die "unknown error" if $sigcount && !$err; # seems to happen sometimes
+ die $err if $err && !wantarray; # assume that user handles timeout err if called in list context
+ return wantarray ? ($res, $got_timeout) : $res;
}
# flock: we use one file handle per process, so lock file
}
# flock: we use one file handle per process, so lock file
$res = $child_res->{result};
$error = $child_res->{error};
};
$res = $child_res->{result};
$error = $child_res->{error};
};
eval {
if (defined($timeout)) {
eval {
if (defined($timeout)) {
- run_with_timeout($timeout, $readvalues);
+ (undef, $got_timeout) = run_with_timeout($timeout, $readvalues);
} else {
$readvalues->();
}
} else {
$readvalues->();
}
die "interrupted by unexpected signal\n" if $sig_received;
die $error if $error;
die "interrupted by unexpected signal\n" if $sig_received;
die $error if $error;
+ return wantarray ? ($res, $got_timeout) : $res;