Expvar successful and unsuccessful dials
This commit is contained in:
parent
8d96195b0c
commit
727aac204f
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue