You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

21 lines
323 B

package transport
import (
"net"
"sync"
)
// onceCloseListener wraps a net.Listener, protecting it from
// multiple Close calls.
type onceCloseListener struct {
net.Listener
once sync.Once
err error
}
func (o *onceCloseListener) Close() error {
o.once.Do(func() {
o.err = o.Listener.Close()
})
return o.err
}