Expvar successful and unsuccessful dials

This commit is contained in:
Matt Joiner 2014-11-17 01:44:06 -06:00
parent 8d96195b0c
commit 727aac204f
1 changed files with 7 additions and 0 deletions

View File

@ -57,6 +57,8 @@ var (
postedCancels = expvar.NewInt("postedCancels") postedCancels = expvar.NewInt("postedCancels")
duplicateConnsAvoided = expvar.NewInt("duplicateConnsAvoided") duplicateConnsAvoided = expvar.NewInt("duplicateConnsAvoided")
failedPieceHashes = expvar.NewInt("failedPieceHashes") failedPieceHashes = expvar.NewInt("failedPieceHashes")
unsuccessfulDials = expvar.NewInt("unsuccessfulDials")
successfulDials = expvar.NewInt("successfulDials")
) )
const ( const (
@ -365,6 +367,11 @@ type dialResult struct {
func doDial(dial func() (net.Conn, error), ch chan dialResult, utp bool) { func doDial(dial func() (net.Conn, error), ch chan dialResult, utp bool) {
conn, err := dial() conn, err := dial()
ch <- dialResult{conn, utp} ch <- dialResult{conn, utp}
if err == nil {
successfulDials.Add(1)
return
}
unsuccessfulDials.Add(1)
if netErr, ok := err.(net.Error); ok && netErr.Timeout() { if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
return return
} }