mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 12:20:52 +08:00
**fix(executor, auth): ensure index assignment consistency for auth objects**
- Updated `usage_helpers.go` to call `EnsureIndex()` for proper index assignment in reporter initialization. - Adjusted `auth/manager.go` to assign auth indices inside a locked section when they are unassigned, ensuring thread safety and consistency.
This commit is contained in:
@@ -37,7 +37,7 @@ func newUsageReporter(ctx context.Context, provider, model string, auth *cliprox
|
|||||||
}
|
}
|
||||||
if auth != nil {
|
if auth != nil {
|
||||||
reporter.authID = auth.ID
|
reporter.authID = auth.ID
|
||||||
reporter.authIndex = auth.Index
|
reporter.authIndex = auth.EnsureIndex()
|
||||||
}
|
}
|
||||||
return reporter
|
return reporter
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1118,6 +1118,14 @@ func (m *Manager) pickNext(ctx context.Context, provider, model string, opts cli
|
|||||||
}
|
}
|
||||||
authCopy := selected.Clone()
|
authCopy := selected.Clone()
|
||||||
m.mu.RUnlock()
|
m.mu.RUnlock()
|
||||||
|
if !selected.indexAssigned {
|
||||||
|
m.mu.Lock()
|
||||||
|
if current := m.auths[authCopy.ID]; current != nil && !current.indexAssigned {
|
||||||
|
current.EnsureIndex()
|
||||||
|
authCopy = current.Clone()
|
||||||
|
}
|
||||||
|
m.mu.Unlock()
|
||||||
|
}
|
||||||
return authCopy, executor, nil
|
return authCopy, executor, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user