summaryrefslogtreecommitdiffstats
path: root/core/templates/lru.h
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2024-07-15 10:30:02 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2024-09-05 13:29:38 +0200
commitb3e46a913d10b029b8ebeb58017e1ce260c42988 (patch)
tree7a044230687080530fcf38d7f36464db2dfd49d8 /core/templates/lru.h
parent8a78f5c323d5d6e6471c2a0182732744e47ea637 (diff)
downloadredot-engine-b3e46a913d10b029b8ebeb58017e1ce260c42988.tar.gz
ResourceLoader: Fix edge cases in the management of user tokens
1. Make handling of user tokens atomic: Loads started with the external-facing API used to perform a two-step setup of the user token. Between both, the mutex was unlocked without its reference count having been increased. A non-user-initiated load could therefore destroy the load task when it unreferenced the token. Those stages now happen atomically so in the one hand, the described race condition can't happen so the load task life insurance doesn't have a gap anymore and, on the other hand, the ugliness that the call to load could return `ERR_BUSY` if happening while other thread was between both steps is gone. The code has been refactored so the user token concerns are still outside the inner load start function, which is agnostic to that for a cleaner implementation. 2. Clear ambiguity between load operations running on `WorkerThreadPool`: The two cases are: single-loaded thread directly started by a user pool task and a load started by the system as part of a multi-threaded load. Since ensuring all the code dealing with this distinction would make it very complex, and error-prone, a different measure is applied instead: just take one of the cases out of the dicotomy. We now ensure every load happening on a pool thread has been initiated by the system. The way of achieving that is that a single-threaded user-started load initiated from a pool thread, is run as another task. (cherry picked from commit df23858488098086da20c67d9fc62f7ffb3d528c)
Diffstat (limited to 'core/templates/lru.h')
0 files changed, 0 insertions, 0 deletions