Gentoo Archives: gentoo-commits

From: "Robin H. Johnson" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-mirrorstats:master commit in: /
Date: Thu, 30 Apr 2020 21:11:10
Message-Id: 1588281059.29f83dc5cca5e06718842753c229bff6f417e244.robbat2@gentoo
1 commit: 29f83dc5cca5e06718842753c229bff6f417e244
2 Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
3 AuthorDate: Thu Apr 30 21:10:59 2020 +0000
4 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 30 21:10:59 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/gentoo-mirrorstats.git/commit/?id=29f83dc5
7
8 probe-mirmon: handle curl error conditions better
9
10 Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
11
12 probe-mirmon | 23 ++++++++++-------------
13 1 file changed, 10 insertions(+), 13 deletions(-)
14
15 diff --git a/probe-mirmon b/probe-mirmon
16 index 1e10ef1..5d99cda 100755
17 --- a/probe-mirmon
18 +++ b/probe-mirmon
19 @@ -53,19 +53,16 @@ sub handle_libcurl {
20 my $retcode = $curl->perform;
21
22 # Looking at the results...
23 - if ($retcode == 0) {
24 - #print("Transfer went ok\n");
25 - my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE);
26 - # judge result and next action based on $response_code
27 - #print("Received response: $response_code $response_body\n");
28 - chomp $response_body;
29 - #print("s='$response_body'\n");
30 - print(munge_date($response_body), "\n");
31 - } else {
32 - # Error code, type of error, error message
33 - #print("An error happened: $retcode ".$curl->strerror($retcode)." ".$curl->errbuf."\n");
34 - exit 800;
35 - }
36 + exit 800 unless ($retcode == 0);
37 +
38 + my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE);
39 + exit 801 unless ($response_code == 200)
40 + exit 802 unless defined($response_body);
41 + chomp $response_body;
42 + print(munge_date($response_body), "\n");
43 +
44 + exit 0;
45 + #print("An error happened: $retcode ".$curl->strerror($retcode)." ".$curl->errbuf."\n");
46
47 }