Skip to content

Commit

Permalink
bug fix on Accept
Browse files Browse the repository at this point in the history
  • Loading branch information
name5566 committed Oct 17, 2015
1 parent f130641 commit 21bb173
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions network/tcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type TCPServer struct {
conns ConnSet
mutexConns sync.Mutex
wg sync.WaitGroup
closeFlag bool

// msg parser
LenMsgLen int
Expand Down Expand Up @@ -50,7 +49,6 @@ func (server *TCPServer) init() {

server.ln = ln
server.conns = make(ConnSet)
server.closeFlag = false

// msg parser
msgParser := NewMsgParser()
Expand All @@ -63,12 +61,7 @@ func (server *TCPServer) run() {
for {
conn, err := server.ln.Accept()
if err != nil {
if server.closeFlag {
return
} else {
log.Error("accept error: %v", err)
continue
}
return
}

server.mutexConns.Lock()
Expand Down Expand Up @@ -101,7 +94,6 @@ func (server *TCPServer) run() {
}

func (server *TCPServer) Close() {
server.closeFlag = true
server.ln.Close()

server.mutexConns.Lock()
Expand Down

0 comments on commit 21bb173

Please sign in to comment.