mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-10 04:00:37 +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")
|
return nil, errors.New("a listener already exists")
|
||||||
}
|
}
|
||||||
c.sessions.listener = &Listener{
|
c.sessions.listener = &Listener{
|
||||||
|
core: c,
|
||||||
conn: make(chan *Conn),
|
conn: make(chan *Conn),
|
||||||
close: make(chan interface{}),
|
close: make(chan interface{}),
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
// Listener waits for incoming sessions
|
// Listener waits for incoming sessions
|
||||||
type Listener struct {
|
type Listener struct {
|
||||||
|
core *Core
|
||||||
conn chan *Conn
|
conn chan *Conn
|
||||||
close chan interface{}
|
close chan interface{}
|
||||||
}
|
}
|
||||||
@ -30,6 +31,9 @@ func (l *Listener) Close() (err error) {
|
|||||||
recover()
|
recover()
|
||||||
err = errors.New("already closed")
|
err = errors.New("already closed")
|
||||||
}()
|
}()
|
||||||
|
if l.core.sessions.listener == l {
|
||||||
|
l.core.sessions.listener = nil
|
||||||
|
}
|
||||||
close(l.close)
|
close(l.close)
|
||||||
close(l.conn)
|
close(l.conn)
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user