From a75c31b4963ada11a7137decaa47e99480a73ddc Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Thu, 22 Mar 2012 23:26:59 +1300 Subject: [PATCH] Reduce the timeout for the child, add more logging. I'm still observing mythtv-status processes hanging around waiting to hear back from MythTV. Which is odd, given the read on the socket connected to MythTV is now happening in the parent. --- bin/mythtv-status | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bin/mythtv-status b/bin/mythtv-status index fa4b71b..44d245d 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -40,6 +40,8 @@ if ($@ && $@ !~ /^No config file found/) { die $@; } +$0 = "mythtv-status - parent"; + # Some sane defaults. $c->{'host'} ||= "localhost"; $c->{'port'} ||= "6544"; @@ -1040,7 +1042,7 @@ sub xml_fetch { eval { local $SIG{ALRM} = sub { die "alarm\n" }; - alarm(30); + alarm(10); $content_type = ; while () { $status .= $_; @@ -1048,19 +1050,25 @@ sub xml_fetch { alarm(0); }; - # The child didn't get back to us in time, kill them off. + # The child didn't get back to us in time, kill them off + # and forget what they sent us. if ($@) { + $status = undef; my $result; + warn "Our child has stopped talking to us, kill it off.\n"; do { kill 9, $pid; $result = waitpid($pid, WNOHANG); } while $result > 0; + + die "Unknown error during retrieval of status from the MythTV backend.\n"; } $| = 0; return ($content_type, $status); } else { # child + $0 = "mythtv-status - child"; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; @@ -1069,8 +1077,8 @@ sub xml_fetch { die "Sorry, failed to fetch $url: Connection to MythTV timed out.\n" unless defined $response; - # If we get a page doesn't exist, then just ignore it, we need to fetch - # the status page from a few different locations. + # If we get a page doesn't exist, then just ignore it, we need to try + # fetching the status page from a few different locations. if ($response->code == 404) { exit 1; } -- 2.30.2