mirror of https://github.com/v2ray/v2ray-core
Merge branch 'master' of https://github.com/v2ray/v2ray-core
commit
8acde086c3
|
@ -158,6 +158,8 @@ func (m *Client) Closed() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Client) monitor() {
|
func (m *Client) monitor() {
|
||||||
|
defer m.manager.onClientFinish()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-m.ctx.Done():
|
case <-m.ctx.Done():
|
||||||
|
@ -166,17 +168,21 @@ func (m *Client) monitor() {
|
||||||
case id := <-m.session2Remove:
|
case id := <-m.session2Remove:
|
||||||
m.access.Lock()
|
m.access.Lock()
|
||||||
delete(m.sessions, id)
|
delete(m.sessions, id)
|
||||||
|
if len(m.sessions) == 0 {
|
||||||
|
m.cancel()
|
||||||
|
}
|
||||||
m.access.Unlock()
|
m.access.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Client) cleanup() {
|
func (m *Client) cleanup() {
|
||||||
defer m.manager.onClientFinish()
|
|
||||||
|
|
||||||
m.access.Lock()
|
m.access.Lock()
|
||||||
defer m.access.Unlock()
|
defer m.access.Unlock()
|
||||||
|
|
||||||
|
m.inboundRay.InboundInput().Close()
|
||||||
|
m.inboundRay.InboundOutput().CloseError()
|
||||||
|
|
||||||
for _, s := range m.sessions {
|
for _, s := range m.sessions {
|
||||||
s.closeUplink()
|
s.closeUplink()
|
||||||
s.closeDownlink()
|
s.closeDownlink()
|
||||||
|
|
Loading…
Reference in New Issue