diff --git a/common/stats/session/session.go b/common/stats/session/session.go index e49384b..0fc3c01 100644 --- a/common/stats/session/session.go +++ b/common/stats/session/session.go @@ -4,7 +4,6 @@ import ( "bufio" "fmt" "io" - "net" "net/http" "sort" "sync" @@ -45,14 +44,6 @@ func (s *simpleSessionStater) Start() error { var sessions []stats.Session s.sessions.Range(func(key, value interface{}) bool { sess := value.(*stats.Session) - // check conn is closed or not - if sess.Network == "tcp" { - conn := key.(net.Conn) - if isClosed(conn) { - s.RemoveSession(conn) - return true - } - } sessions = append(sessions, *sess) return true }) diff --git a/common/stats/session/utils.go b/common/stats/session/utils.go index 0abdc40..5b87578 100644 --- a/common/stats/session/utils.go +++ b/common/stats/session/utils.go @@ -2,8 +2,6 @@ package session import ( "fmt" - "io" - "net" "strings" "time" ) @@ -96,17 +94,3 @@ func diff(a, b time.Time) (year, month, day, hour, min, sec int) { return } - -func isClosed(conn net.Conn) bool { - conn.SetReadDeadline(time.Now()) - _, err := conn.Read([]byte{}) - if err != nil { - if err == io.EOF { - conn.Close() - return true - } else if strings.Contains(err.Error(), "use of closed network connection") { - return true - } - } - return false -}