Browse Source

remove last commit

pull/15/head
Jason 5 years ago
parent
commit
e92d253cc3
  1. 9
      common/stats/session/session.go
  2. 16
      common/stats/session/utils.go

9
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
})

16
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
}

Loading…
Cancel
Save