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
|
return nil, err
|
||||||
}
|
}
|
||||||
l.counter <- inc
|
select {
|
||||||
return conn{
|
case <-l.allClosed:
|
||||||
Conn: c,
|
c.Close()
|
||||||
counter: l.counter,
|
return nil, ErrAlreadyClosed
|
||||||
}, nil
|
case l.counter <- inc:
|
||||||
|
return conn{
|
||||||
|
Conn: c,
|
||||||
|
counter: l.counter,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
panic("not reached")
|
panic("not reached")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user