Skip to content

Commit

Permalink
update connect method
Browse files Browse the repository at this point in the history
  • Loading branch information
name5566 committed Oct 19, 2015
1 parent 31a8c01 commit f12f0eb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions network/tcp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,18 @@ func (client *TCPClient) connect() {
return
}

client.wg.Add(1)
defer client.wg.Done()

client.Lock()
if client.closeFlag {
conn.Close()
client.Unlock()
conn.Close()
return
}
client.conns[conn] = struct{}{}
client.Unlock()

client.wg.Add(1)

tcpConn := newTCPConn(conn, client.PendingWriteNum, client.msgParser)
agent := client.NewAgent(tcpConn)
agent.Run()
Expand All @@ -107,8 +108,6 @@ func (client *TCPClient) connect() {
delete(client.conns, conn)
client.Unlock()
agent.OnClose()

client.wg.Done()
}

func (client *TCPClient) Close() {
Expand Down

0 comments on commit f12f0eb

Please sign in to comment.