mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-18 11:05:02 +03:00
fix(traffic): commit a traffic tick even when a best-effort maintenance helper fails
addTrafficLocked stages the inbound and client deltas, then runs three helpers (auto-renew, disable depleted clients, disable depleted inbounds) that are meant to log and continue. All three reused the function-scope err that the deferred commit/rollback inspects, so the last helper's error decided the whole tick: a failure in disableInvalidInbounds rolled back the already-staged traffic while AddTraffic reported success, and because xray had already advanced its counter baseline that traffic was lost for good. Give each best-effort helper its own error variable so only a genuine staging failure rolls the tick back.
This commit is contained in:
@@ -51,25 +51,25 @@ func (s *InboundService) addTrafficLocked(inboundTraffics []*xray.Traffic, clien
|
||||
return false, false, err
|
||||
}
|
||||
|
||||
needRestart0, count, err := s.autoRenewClients(tx)
|
||||
if err != nil {
|
||||
logger.Warning("Error in renew clients:", err)
|
||||
needRestart0, count, renewErr := s.autoRenewClients(tx)
|
||||
if renewErr != nil {
|
||||
logger.Warning("Error in renew clients:", renewErr)
|
||||
} else if count > 0 {
|
||||
logger.Debugf("%v clients renewed", count)
|
||||
}
|
||||
|
||||
disabledClientsCount := int64(0)
|
||||
needRestart1, count, err := s.disableInvalidClients(tx)
|
||||
if err != nil {
|
||||
logger.Warning("Error in disabling invalid clients:", err)
|
||||
needRestart1, count, disableClientsErr := s.disableInvalidClients(tx)
|
||||
if disableClientsErr != nil {
|
||||
logger.Warning("Error in disabling invalid clients:", disableClientsErr)
|
||||
} else if count > 0 {
|
||||
logger.Debugf("%v clients disabled", count)
|
||||
disabledClientsCount = count
|
||||
}
|
||||
|
||||
needRestart2, count, err := s.disableInvalidInbounds(tx)
|
||||
if err != nil {
|
||||
logger.Warning("Error in disabling invalid inbounds:", err)
|
||||
needRestart2, count, disableInboundsErr := s.disableInvalidInbounds(tx)
|
||||
if disableInboundsErr != nil {
|
||||
logger.Warning("Error in disabling invalid inbounds:", disableInboundsErr)
|
||||
} else if count > 0 {
|
||||
logger.Debugf("%v inbounds disabled", count)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user