1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-29 00:24:14 +00:00

add mutex

This commit is contained in:
astaxie 2013-06-26 22:16:03 +08:00
parent 573df2e747
commit 71adbdd7d7

View File

@ -29,9 +29,12 @@ type conn struct {
net.Conn net.Conn
wg *sync.WaitGroup wg *sync.WaitGroup
isclose bool isclose bool
lock sync.Mutex
} }
func (c conn) Close() error { func (c conn) Close() error {
c.lock.Lock()
defer c.lock.Unlock()
err := c.Conn.Close() err := c.Conn.Close()
if !c.isclose { if !c.isclose {
c.wg.Done() c.wg.Done()