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,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")
} }