|
@@ -121,13 +121,12 @@ func (m *Client) monitor() {
|
|
|
for {
|
|
for {
|
|
|
select {
|
|
select {
|
|
|
case <-m.ctx.Done():
|
|
case <-m.ctx.Done():
|
|
|
- m.sessionManager.Close()
|
|
|
|
|
m.inboundRay.InboundInput().Close()
|
|
m.inboundRay.InboundInput().Close()
|
|
|
m.inboundRay.InboundOutput().CloseError()
|
|
m.inboundRay.InboundOutput().CloseError()
|
|
|
return
|
|
return
|
|
|
case <-time.After(time.Second * 6):
|
|
case <-time.After(time.Second * 6):
|
|
|
size := m.sessionManager.Size()
|
|
size := m.sessionManager.Size()
|
|
|
- if size == 0 {
|
|
|
|
|
|
|
+ if size == 0 && m.sessionManager.CloseIfNoSession() {
|
|
|
m.cancel()
|
|
m.cancel()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -169,12 +168,12 @@ func (m *Client) Dispatch(ctx context.Context, outboundRay ray.OutboundRay) bool
|
|
|
default:
|
|
default:
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- s := &Session{
|
|
|
|
|
- input: outboundRay.OutboundInput(),
|
|
|
|
|
- output: outboundRay.OutboundOutput(),
|
|
|
|
|
- parent: m.sessionManager,
|
|
|
|
|
|
|
+ s := m.sessionManager.Allocate()
|
|
|
|
|
+ if s == nil {
|
|
|
|
|
+ return false
|
|
|
}
|
|
}
|
|
|
- m.sessionManager.Allocate(s)
|
|
|
|
|
|
|
+ s.input = outboundRay.OutboundInput()
|
|
|
|
|
+ s.output = outboundRay.OutboundOutput()
|
|
|
go fetchInput(ctx, s, m.inboundRay.InboundInput())
|
|
go fetchInput(ctx, s, m.inboundRay.InboundInput())
|
|
|
return true
|
|
return true
|
|
|
}
|
|
}
|