mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-05 03:38:40 +00:00
Add maxReuseTimes
This commit is contained in:
parent
4ce65fc74c
commit
c55beec5a9
6 changed files with 36 additions and 14 deletions
|
@ -166,7 +166,7 @@ func (f *DialingWorkerFactory) Create() (*ClientWorker, error) {
|
|||
|
||||
type ClientStrategy struct {
|
||||
MaxConcurrency uint32
|
||||
MaxConnection uint32
|
||||
MaxReuseTimes uint32
|
||||
}
|
||||
|
||||
type ClientWorker struct {
|
||||
|
@ -270,7 +270,7 @@ func fetchInput(ctx context.Context, s *Session, output buf.Writer) {
|
|||
|
||||
func (m *ClientWorker) IsClosing() bool {
|
||||
sm := m.sessionManager
|
||||
if m.strategy.MaxConnection > 0 && sm.Count() >= int(m.strategy.MaxConnection) {
|
||||
if m.strategy.MaxReuseTimes > 0 && sm.Count() >= int(m.strategy.MaxReuseTimes) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
@ -298,6 +298,8 @@ func (m *ClientWorker) Dispatch(ctx context.Context, link *transport.Link) bool
|
|||
if s == nil {
|
||||
return false
|
||||
}
|
||||
errors.LogInfo(ctx, "allocated mux.cool subConnection ID: ", s.ID, "/", m.strategy.MaxReuseTimes)
|
||||
errors.LogInfo(ctx, "living subConnections:", sm.Size() , "/", m.strategy.MaxConcurrency)
|
||||
s.input = link.Reader
|
||||
s.output = link.Writer
|
||||
go fetchInput(ctx, s, m.link.Writer)
|
||||
|
|
|
@ -58,7 +58,7 @@ func TestClientWorkerClose(t *testing.T) {
|
|||
Writer: w1,
|
||||
}, mux.ClientStrategy{
|
||||
MaxConcurrency: 4,
|
||||
MaxConnection: 4,
|
||||
MaxReuseTimes: 4,
|
||||
})
|
||||
common.Must(err)
|
||||
|
||||
|
@ -68,7 +68,7 @@ func TestClientWorkerClose(t *testing.T) {
|
|||
Writer: w2,
|
||||
}, mux.ClientStrategy{
|
||||
MaxConcurrency: 4,
|
||||
MaxConnection: 4,
|
||||
MaxReuseTimes: 4,
|
||||
})
|
||||
common.Must(err)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue