From: Daniel Kahn Gillmor Date: Mon, 18 Oct 2010 05:12:11 +0000 (-0400) Subject: handle non-responsive agents more politely X-Git-Tag: msva-perl_debian/0.6-1~3^2~26 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d3db08e0baf3457b9b8966af3a556bc4e2d7112b;p=monkeysphere-validation-agent.git handle non-responsive agents more politely --- diff --git a/Crypt/Monkeysphere/MSVA/Client.pm b/Crypt/Monkeysphere/MSVA/Client.pm index 0d91aad..8b6e514 100644 --- a/Crypt/Monkeysphere/MSVA/Client.pm +++ b/Crypt/Monkeysphere/MSVA/Client.pm @@ -79,7 +79,10 @@ my $response = $ua->request($request); my $status = $response->status_line; - my $ret = from_json($response->content); + my $ret; + if ($status eq '200 OK') { + $ret = from_json($response->content); + } return $status, $ret; } diff --git a/msva-query-agent b/msva-query-agent index 846d27d..1c77282 100755 --- a/msva-query-agent +++ b/msva-query-agent @@ -35,15 +35,14 @@ my $pkcdata = do { my ($status,$ret) = Crypt::Monkeysphere::MSVA::Client->query_agent($context,$peer,$pkctype, $pkcdata, $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET}); msvalog('info', "status: %s\n", $status); -msvalog('info', "valid: %s\n", $ret->{valid}); -msvalog('info', "message: %s\n", $ret->{message}); - -if ($ret->{valid}) { - exit 0; -} -else { - exit 1; +if (defined $ret) { + msvalog('info', "valid: %s\n", $ret->{valid}); + msvalog('fatal', "message: %s\n", $ret->{message}); + exit 0 + if ($ret->{valid}); } +exit 1; + __END__ =head1 NAME