#in waitpid()
$SIG{CHLD} = sub {
my $kid;
- log_debug { "CHLD signal handler is executing" };
+ log_trace { "CHLD signal handler is executing" };
do {
$kid = waitpid(-1, WNOHANG);
- log_trace { "waitpid() returned '$kid'" };
+ log_debug { "waitpid() returned '$kid'" };
} while $kid > 0;
log_trace { "CHLD signal handler is done" };
- };
+ };
+
+ $SIG{PIPE} = sub { log_debug { "Got a PIPE signal" } };
}
END {
};
-
has on_close => (
is => 'rw', default => sub { CPS::Future->new },
trigger => sub {
my ($self, $error) = @_;
Dlog_debug { "Failing outstanding futures with '$error' for connection $_" } $self->_id;
my $outstanding = $self->outstanding_futures;
- $_->fail($error) for values %$outstanding;
+ $_->fail("$error\n") for values %$outstanding;
%$outstanding = ();
return;
}
log_trace { "Checking timers" };
while (@$timers and $timers->[0][0] <= $now) {
my $active = $timers->[0];
- Dlog_debug { "Found timer that needs to be executed: '$active'" };
+ Dlog_trace { "Found timer that needs to be executed: '$active'" };
if (defined($active->[2])) {
#handle the case of an 'every' timer
use Object::Remote::Handle;
use Object::Remote::Future;
use Scalar::Util qw(blessed weaken);
+use POSIX;
use Moo::Role;
use Symbol;
on_read_ready => sub {
my $buf = '';
my $len = sysread($foreign_stderr, $buf, 32768);
- if (!defined($len) or $len == 0) {
+ if ((!defined($len) && $! != EAGAIN) or $len == 0) {
log_trace { "Got EOF or error on child stderr, removing from watcher" };
$self->stderr(undef);
Object::Remote->current_loop
}
# if the stdin went away, we'll never get Shere
# so it's not a big deal to simply give up on !defined
- if (!defined($len) or 0 == length($to_send)) {
+ if ((!defined($len) && $! != EAGAIN) or 0 == length($to_send)) {
log_trace { "Got EOF or error when writing fatnode data to filehandle, unwatching it" };
Object::Remote->current_loop
->unwatch_io(
return unless $self->watchdog_timeout;
Dlog_trace { "Creating Watchdog management timer for connection id $_" } $conn->_id;
-
+
+ weaken($conn);
+
$timer_id = Object::Remote->current_loop->watch_time(
every => $self->watchdog_timeout / 3,
code => sub {
return;
}
- Dlog_debug { "Reseting Watchdog for connection id $_" } $conn->_id;
+ Dlog_trace { "Reseting Watchdog for connection id $_" } $conn->_id;
#we do not want to block in the run loop so send the
#update off and ignore any result, we don't need it
#anyway
$conn->send_class_call(0, 'Object::Remote::WatchDog', 'reset');
}
- );
-
- $conn->on_close->on_done(sub { Object::Remote->current_loop->unwatch_time($timer_id) });
+ );
}
sub fatnode_text {
require Object::Remote::FatNode;
- $text = "my \$WATCHDOG_TIMEOUT = '" . $self->watchdog_timeout . "';\n";
-
- if (my $duration = $self->watchdog_timeout) {
+ if (defined($self->watchdog_timeout)) {
+ $text = "my \$WATCHDOG_TIMEOUT = '" . $self->watchdog_timeout . "';\n";
$text .= "alarm(\$WATCHDOG_TIMEOUT);\n";
+ } else {
+ $text = "my \$WATCHDOG_TIMEOUT = undef;\n";
}
-
+
$text .= 'BEGIN { $ENV{OBJECT_REMOTE_DEBUG} = 1 }'."\n"
if $ENV{OBJECT_REMOTE_DEBUG};
$text .= <<'END';