Skip to content

Commit

Permalink
fix potential segfalt and make golint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
fffw committed Sep 22, 2015
1 parent bc89d59 commit d4a1238
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/github.com/getlantern/checkfallbacks/checkfallbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func testAllFallbacks(fallbacks []client.ChainedServerInfo) (output *chan fullOu
}

// Perform the test of an individual server
func testFallbackServer(fb *client.ChainedServerInfo, workerId int) (output fullOutput) {
func testFallbackServer(fb *client.ChainedServerInfo, workerID int) (output fullOutput) {
// Test connectivity
fb.Pipelined = true
dialer, err := fb.Dialer()
Expand All @@ -145,7 +145,11 @@ func testFallbackServer(fb *client.ChainedServerInfo, workerId int) (output full
},
}
req, err := http.NewRequest("GET", "http://www.google.com/humans.txt", nil)
if *verbose && err == nil {
if err != nil {
output.err = fmt.Errorf("%v: NewRequest to humans.txt failed: %v", fb.Addr, err)
return
}
if *verbose {
reqStr, _ := httputil.DumpRequestOut(req, true)
output.info = []string{"\n" + string(reqStr)}
}
Expand All @@ -155,11 +159,10 @@ func testFallbackServer(fb *client.ChainedServerInfo, workerId int) (output full
if err != nil {
output.err = fmt.Errorf("%v: requesting humans.txt failed: %v", fb.Addr, err)
return
} else {
if *verbose {
respStr, _ := httputil.DumpResponse(resp, true)
output.info = append(output.info, "\n"+string(respStr))
}
}
if *verbose {
respStr, _ := httputil.DumpResponse(resp, true)
output.info = append(output.info, "\n"+string(respStr))
}
defer func() {
if err := resp.Body.Close(); err != nil {
Expand All @@ -181,7 +184,7 @@ func testFallbackServer(fb *client.ChainedServerInfo, workerId int) (output full
return
}

log.Debugf("Worker %d: Fallback %v OK.\n", workerId, fb.Addr)
log.Debugf("Worker %d: Fallback %v OK.\n", workerID, fb.Addr)

if *verify {
verifyFallback(fb, c)
Expand Down

0 comments on commit d4a1238

Please sign in to comment.