5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-10 05:10:26 +00:00

Listener should clean up a bit more when closing

This commit is contained in:
Neil Alexander 2019-04-19 23:04:09 +01:00
parent aac88adbed
commit 7e726b0afb
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
2 changed files with 5 additions and 0 deletions

View File

@ -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{}),
}

View File

@ -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