-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Open
Description
P2: IsRateLimited reads _nextAvailable without synchronization while BeginRateLimit writes it under a lock. The timer thread can observe stale state and raise TokenBecameAvailable early. Guard the read with the same lock (or use a volatile/interlocked read).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Client/TokenBase.cs, line 67:
<comment>IsRateLimited reads _nextAvailable without synchronization while BeginRateLimit writes it under a lock. The timer thread can observe stale state and raise TokenBecameAvailable early. Guard the read with the same lock (or use a volatile/interlocked read).</comment>
<file context>
@@ -0,0 +1,85 @@
+ /// <summary>
+ /// Returns true while the token is rate limited.
+ /// </summary>
+ public bool IsRateLimited => _nextAvailable > DateTime.UtcNow;
+
+ /// <summary>
</file context>
Originally posted by @cubic-dev-ai[bot] in #23260 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels