Fix TestGracefulStop flakiness (#1767)
This commit is contained in:
@ -38,6 +38,7 @@ type delayListener struct {
|
|||||||
acceptCalled chan struct{}
|
acceptCalled chan struct{}
|
||||||
allowCloseCh chan struct{}
|
allowCloseCh chan struct{}
|
||||||
cc *delayConn
|
cc *delayConn
|
||||||
|
dialed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *delayListener) Accept() (net.Conn, error) {
|
func (d *delayListener) Accept() (net.Conn, error) {
|
||||||
@ -70,6 +71,13 @@ func (d *delayListener) allowClientRead() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *delayListener) Dial(to time.Duration) (net.Conn, error) {
|
func (d *delayListener) Dial(to time.Duration) (net.Conn, error) {
|
||||||
|
if d.dialed {
|
||||||
|
// Only hand out one connection (net.Dial can return more even after the
|
||||||
|
// listener is closed). This is not thread-safe, but Dial should never be
|
||||||
|
// called concurrently in this environment.
|
||||||
|
return nil, fmt.Errorf("no more conns")
|
||||||
|
}
|
||||||
|
d.dialed = true
|
||||||
c, err := net.DialTimeout("tcp", d.Listener.Addr().String(), to)
|
c, err := net.DialTimeout("tcp", d.Listener.Addr().String(), to)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Reference in New Issue
Block a user