From d3db08e0baf3457b9b8966af3a556bc4e2d7112b Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Mon, 18 Oct 2010 01:12:11 -0400 Subject: [PATCH] handle non-responsive agents more politely --- Crypt/Monkeysphere/MSVA/Client.pm | 5 ++++- msva-query-agent | 15 +++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) 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 -- 2.26.2