Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
gansidui committed Oct 9, 2015
1 parent 4745093 commit bc20b14
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions conn.go
Expand Up @@ -121,17 +121,18 @@ func (c *Conn) AsyncWritePacket(p Packet, timeout time.Duration) (err error) {

// Do it
func (c *Conn) Do() {
defer c.srv.waitGroup.Done()

This comment has been minimized.

Copy link
@ronalfei

ronalfei Oct 30, 2015

这么干不好吧, 在哪add的都不知道

if !c.srv.callback.OnConnect(c) {
return
}

c.srv.waitGroup.Add(3)

This comment has been minimized.

Copy link
@ronalfei

ronalfei Oct 30, 2015

这么干不好吧. 是否应该和原来一样写到Loop函数里去add(1)?

go c.handleLoop()
go c.readLoop()
go c.writeLoop()
}

func (c *Conn) readLoop() {
c.srv.waitGroup.Add(1)
defer func() {
recover()
c.Close()
Expand Down Expand Up @@ -159,7 +160,6 @@ func (c *Conn) readLoop() {
}

func (c *Conn) writeLoop() {
c.srv.waitGroup.Add(1)
defer func() {
recover()
c.Close()
Expand All @@ -186,7 +186,6 @@ func (c *Conn) writeLoop() {
}

func (c *Conn) handleLoop() {
c.srv.waitGroup.Add(1)
defer func() {
recover()
c.Close()
Expand Down
1 change: 1 addition & 0 deletions server.go
Expand Up @@ -53,6 +53,7 @@ func (s *Server) Start(listener *net.TCPListener, acceptTimeout time.Duration) {
continue
}

s.waitGroup.Add(1)
go newConn(conn, s).Do()
}
}
Expand Down

1 comment on commit bc20b14

@gansidui
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯,之前那个写到一起可能会存在问题,现在已经修正。

Please sign in to comment.