diff options
author | Leah Neukirchen <leah@vuxu.org> | 2020-03-15 00:41:38 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2020-03-15 00:41:38 +0100 |
commit | 10d94786ec39dc639d005134526281293cb0c802 (patch) | |
tree | 337133a00272e56b882dc7b96d79b657ee6b4f17 | |
parent | 30eef8f7202af3cd09cd371b356d31c97a0573b1 (diff) | |
download | htping-10d94786ec39dc639d005134526281293cb0c802.tar.gz htping-10d94786ec39dc639d005134526281293cb0c802.tar.xz htping-10d94786ec39dc639d005134526281293cb0c802.zip |
simplify handling of failed requests
-rw-r--r-- | htping.go | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/htping.go b/htping.go index f933814..ca2ee34 100644 --- a/htping.go +++ b/htping.go @@ -120,7 +120,6 @@ func ping(url string, seq int, results chan result) { req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Printf("error=%v\n", err) - results <- result{0, -1} return } @@ -143,7 +142,6 @@ func ping(url string, seq int, results chan result) { res, err := client.Do(req) if err != nil { fmt.Printf("error=%v\n", err) - results <- result{0, -1} return } @@ -180,19 +178,17 @@ func stats(results chan result, done chan bool) { for { select { case r := <-results: - if r.code > 0 { - if r.dur < min { - min = r.dur - } - if r.dur > max { - max = r.dur - } - sum += r.dur - sum2 += r.dur * r.dur - nrecv++ - if r.code <= 400 { - nsucc++ - } + if r.dur < min { + min = r.dur + } + if r.dur > max { + max = r.dur + } + sum += r.dur + sum2 += r.dur * r.dur + nrecv++ + if r.code <= 400 { + nsucc++ } case <-done: |