Skip to content

Commit

Permalink
perf: 解析命令增加超时,完善命令上传
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeEirc authored and BaiJiangJie committed Jun 14, 2023
1 parent e7f814b commit 1d80909
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/proxy/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ func (p *Parser) ParseStream(userInChan chan *exchange.RoomMessage, srvInChan <-
p.zmodemParser.Cleanup()
logger.Infof("Session %s: Parser routine done", p.id)
}()
cmdRecordTicker := time.NewTicker(time.Minute)
defer cmdRecordTicker.Stop()
lastActiveTime := time.Now()
for {
select {
case <-p.closed:
Expand Down Expand Up @@ -138,8 +141,14 @@ func (p *Parser) ParseStream(userInChan chan *exchange.RoomMessage, srvInChan <-
return
case p.srvOutputChan <- b:
}

case now := <-cmdRecordTicker.C:
// 每隔一分钟超时,尝试结算一次命令
if now.Sub(lastActiveTime) > time.Minute {
p.sendCommandRecord()
}
continue
}
lastActiveTime = time.Now()
}
}()
return p.userOutputChan, p.srvOutputChan
Expand Down

0 comments on commit 1d80909

Please sign in to comment.