drop connections that come in between a close and an accept race
this is bad, but worse is the current logic which can sometimes hit a nil counter channel.
This commit is contained in:
parent
249c1519e3
commit
8f7f9df910
15
grace.go
15
grace.go
@ -135,11 +135,16 @@ func (l *listener) Accept() (net.Conn, error) {
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
l.counter <- inc
|
||||
return conn{
|
||||
Conn: c,
|
||||
counter: l.counter,
|
||||
}, nil
|
||||
select {
|
||||
case <-l.allClosed:
|
||||
c.Close()
|
||||
return nil, ErrAlreadyClosed
|
||||
case l.counter <- inc:
|
||||
return conn{
|
||||
Conn: c,
|
||||
counter: l.counter,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
panic("not reached")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user