Cockatrice/cockatrice
BruebachL 3d5eb84d81
[PictureLoader] Seed per-host allowances on demand and skip hosts in 429 backoff (#7286)
* [PictureLoader] Seed per-host allowances on demand and skip hosts in 429 backoff

The quota reset re-filled every host's remaining allowance to a full
MAX_REQUESTS_PER_SEC as soon as the queue had a request for it, so a server
that was just rate limited could be hammered again at full speed immediately
after (or even during) recovery.

Only seed a host's allowance the first time it is dispatched in the current
second, seeded from its reduced sustained quota, and skip hosts still inside
their 429 backoff window entirely, handing the entry back to its worker so it
can wait the backoff out or fall through to another source instead of parking
in the queue with no reply pending. Deferrals wait on the host that is
actually blocking the request (cached-redirect targets and the reply host of
a 429) rather than the current card URL's host.

Rebased onto network-requests/request-pacing, which absorbed the earlier
pacing and dispatch-guard commits, and reuses its updateTimerState idle-429
recovery plumbing.

* [PictureLoader] Hand backed-off entries back across the whole dispatch tick

Review fixes on the 429-backoff skip:

- Hand a backed-off queue entry back to its worker via
  scheduleDeferredRetry(host) instead of startNextPicDownload(), which was
  looping on the pre-redirect host every 100ms tick whenever the queued URL
  was a cached-redirect target whose redirect host was the one in backoff.
- Keep scanning the queue after a hand-back (--i; continue) so a backed-off
  host at the head no longer consumes the entire dispatch tick, stalling
  every healthy host further down.
- Emit imageRequestSucceeded(url) before makeRequest()'s cached-redirect
  backoff return so the status bar reclaims the deferred URL's widget instead
  of inflating the progress bar forever.
- Only spend a per-second allowance when makeRequest() actually issues a
  request: it returns nullptr when the redirect target is backed off and the
  work is handed back, so the slot would otherwise be wasted on a no-op.
- Gate the dispatch-time backoff skip on requestTouchesNetwork() so entries
  served straight from the disk cache (e.g. with downloads disabled) are not
  bounced into a 30-60s deferred retry for a host that 429'd earlier.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-09-21 18:30:03 +02:00
..
resources [Client] Create custom pawn for dev role (#7295) 2026-09-18 10:58:10 -07:00
sounds Add cmake format (#4618) 2022-05-08 21:22:43 +02:00
src [PictureLoader] Seed per-host allowances on demand and skip hosts in 429 backoff (#7286) 2026-09-21 18:30:03 +02:00
themes [Themes] Add identity default palettes for the image themes (#7280) 2026-09-18 15:16:07 +02:00
translations Update translation files (#7044) 2026-07-16 09:07:33 +02:00
.qdevelop icon_draw and icon_untap added, icon_general and icon_messages modified 2009-07-31 13:37:16 +02:00
CMakeLists.txt [DeckShare] Browse and open public decks with loading, error and accessibility states (#7245) 2026-09-20 20:22:17 +02:00
cockatrice-cod.xml Define Cockatrice as an editor/handler for .cod files and cockatrice:// protocol on all platforms (#6775) 2026-08-08 19:02:19 +02:00
cockatrice.desktop Define Cockatrice as an editor/handler for .cod files and cockatrice:// protocol on all platforms (#6775) 2026-08-08 19:02:19 +02:00
cockatrice.qrc [Client] Create custom pawn for dev role (#7295) 2026-09-18 10:58:10 -07:00
cockatrice.rc Included uninstaller for Windows version 2010-09-17 15:26:07 +02:00
cockatrice_en@source.ts Update translation source strings (#7028) 2026-07-01 16:25:10 +02:00