From: Andrew Ruthven Date: Thu, 22 Mar 2012 10:26:59 +0000 (+1300) Subject: Reduce the timeout for the child, add more logging. X-Git-Tag: debian-0.10.0-1~5 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a75c31b4963ada11a7137decaa47e99480a73ddc;p=mythtv-status.git 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. --- 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; }