add isclose call close many times
Showing
1 changed file
with
6 additions
and
2 deletions
| ... | @@ -27,12 +27,16 @@ var ErrInitStart = errors.New("init from") | ... | @@ -27,12 +27,16 @@ var ErrInitStart = errors.New("init from") |
| 27 | // Allows for us to notice when the connection is closed. | 27 | // Allows for us to notice when the connection is closed. |
| 28 | type conn struct { | 28 | type conn struct { |
| 29 | net.Conn | 29 | net.Conn |
| 30 | wg *sync.WaitGroup | 30 | wg *sync.WaitGroup |
| 31 | isclose bool | ||
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | func (c conn) Close() error { | 34 | func (c conn) Close() error { |
| 34 | err := c.Conn.Close() | 35 | err := c.Conn.Close() |
| 35 | c.wg.Done() | 36 | if !c.isclose { |
| 37 | c.wg.Done() | ||
| 38 | c.isclose = true | ||
| 39 | } | ||
| 36 | return err | 40 | return err |
| 37 | } | 41 | } |
| 38 | 42 | ... | ... |
-
Please register or sign in to post a comment