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:
Naitik Shah 2013-04-03 18:11:40 -07:00
parent 249c1519e3
commit 8f7f9df910

View File

@ -135,12 +135,17 @@ func (l *listener) Accept() (net.Conn, error) {
}
return nil, err
}
l.counter <- inc
select {
case <-l.allClosed:
c.Close()
return nil, ErrAlreadyClosed
case l.counter <- inc:
return conn{
Conn: c,
counter: l.counter,
}, nil
}
}
panic("not reached")
}