`closed` field of SnowflakeListener is never initialized
SnowflakeListener
is:
type SnowflakeListener struct {
addr net.Addr
queue chan net.Conn
server *http.Server
ln *kcp.Listener
closed chan struct{}
closeOnce sync.Once
}
When it is initialized, its queue
channel is initialized but its closed
channel is left nil
:
listener := &SnowflakeListener{addr: addr, queue: make(chan net.Conn, 65534)}
The effect of this is that in functions such as SnowflakeListener.queueConn
, the select
will never take the closed
case, because reads from nil
channels always block:
func (l *SnowflakeListener) queueConn(conn net.Conn) error {
select {
case <-l.closed:
return fmt.Errorf("accepted connection on closed listener")
case l.queue <- conn:
return nil
}
}