Ensure that the WaitGroup isn't marked done twice when edgecase errors occurr
This commit is contained in:
parent
d2b7f5f03a
commit
e068b65c78
12
grace.go
12
grace.go
@ -59,11 +59,15 @@ type deadliner interface {
|
|||||||
// Allows for us to notice when the connection is closed.
|
// Allows for us to notice when the connection is closed.
|
||||||
type conn struct {
|
type conn struct {
|
||||||
net.Conn
|
net.Conn
|
||||||
wg *sync.WaitGroup
|
wg *sync.WaitGroup
|
||||||
|
closed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c conn) Close() error {
|
func (c *conn) Close() error {
|
||||||
defer c.wg.Done()
|
if !c.closed {
|
||||||
|
c.closed = true
|
||||||
|
defer c.wg.Done()
|
||||||
|
}
|
||||||
return c.Conn.Close()
|
return c.Conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +137,7 @@ func (l *listener) Accept() (net.Conn, error) {
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return conn{Conn: c, wg: &l.wg}, nil
|
return &conn{Conn: c, wg: &l.wg}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type Process struct {
|
type Process struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user