add mutex
Showing
1 changed file
with
3 additions
and
0 deletions
| ... | @@ -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() | ... | ... |
-
Please register or sign in to post a comment