mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-12-27 02:25:40 +00:00
Listener should clean up a bit more when closing
This commit is contained in:
parent
aac88adbed
commit
7e726b0afb
@ -262,6 +262,7 @@ func (c *Core) ListenConn() (*Listener, error) {
|
||||
return nil, errors.New("a listener already exists")
|
||||
}
|
||||
c.sessions.listener = &Listener{
|
||||
core: c,
|
||||
conn: make(chan *Conn),
|
||||
close: make(chan interface{}),
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
// Listener waits for incoming sessions
|
||||
type Listener struct {
|
||||
core *Core
|
||||
conn chan *Conn
|
||||
close chan interface{}
|
||||
}
|
||||
@ -30,6 +31,9 @@ func (l *Listener) Close() (err error) {
|
||||
recover()
|
||||
err = errors.New("already closed")
|
||||
}()
|
||||
if l.core.sessions.listener == l {
|
||||
l.core.sessions.listener = nil
|
||||
}
|
||||
close(l.close)
|
||||
close(l.conn)
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user