mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-11-06 10:12:37 +00:00
Improve idle connection management
This commit is contained in:
@@ -94,7 +94,7 @@ func NewCommandServer(handler CommandServerHandler, platformInterface PlatformIn
|
||||
OOMRecorder: oomRecorder,
|
||||
})
|
||||
if sPowerReportEnabled {
|
||||
err := powerManager.Start(PowerReportOptions(server.StartedService))
|
||||
err := powerManager.Start(PowerReportOptions(server.StartedService, platformInterface))
|
||||
if err != nil {
|
||||
log.StdLogger().Error(E.Cause(err, "start power report recorder"))
|
||||
}
|
||||
@@ -258,14 +258,19 @@ func (s *CommandServer) NeedFindProcess() bool {
|
||||
func (s *CommandServer) Pause() {
|
||||
recorder := s.powerManager.Recorder()
|
||||
if recorder != nil {
|
||||
recorder.RecordPlatformEvent("ne-sleep")
|
||||
recorder.RecordDeviceSleep()
|
||||
}
|
||||
instance := s.StartedService.Instance()
|
||||
if instance == nil || instance.PauseManager() == nil {
|
||||
return
|
||||
}
|
||||
instance.Box().CloseIdleConnections()
|
||||
instance.PauseManager().DevicePause()
|
||||
if C.IsIos {
|
||||
// iOS calls wake within seconds of sleep while the device stays locked, so wake is
|
||||
// ignored and the pause ends one minute after the last sleep instead. Go timers on
|
||||
// darwin run on CLOCK_UPTIME_RAW, which does not advance while the device sleeps,
|
||||
// so the minute counts awake time only and never expires inside a sleep.
|
||||
if s.endPauseTimer == nil {
|
||||
s.endPauseTimer = time.AfterFunc(time.Minute, s.endDevicePause)
|
||||
} else {
|
||||
@@ -285,7 +290,7 @@ func (s *CommandServer) endDevicePause() {
|
||||
func (s *CommandServer) Wake() {
|
||||
recorder := s.powerManager.Recorder()
|
||||
if recorder != nil {
|
||||
recorder.RecordPlatformEvent("ne-wake")
|
||||
recorder.RecordDeviceWake()
|
||||
}
|
||||
instance := s.StartedService.Instance()
|
||||
if instance == nil || instance.PauseManager() == nil {
|
||||
|
||||
Reference in New Issue
Block a user