71adbdd7 by astaxie

add mutex

1 parent 573df2e7
...@@ -29,9 +29,12 @@ type conn struct { ...@@ -29,9 +29,12 @@ type conn struct {
29 net.Conn 29 net.Conn
30 wg *sync.WaitGroup 30 wg *sync.WaitGroup
31 isclose bool 31 isclose bool
32 lock sync.Mutex
32 } 33 }
33 34
34 func (c conn) Close() error { 35 func (c conn) Close() error {
36 c.lock.Lock()
37 defer c.lock.Unlock()
35 err := c.Conn.Close() 38 err := c.Conn.Close()
36 if !c.isclose { 39 if !c.isclose {
37 c.wg.Done() 40 c.wg.Done()
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!