mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
Every API request reloads the skills and agents metadata stores and swaps the server's pointers under s.mu, but several handlers read or wrote the stores outside that lock: listing, skill detail, check, the update stream, and the hash refresh after setting targets. Concurrent requests could race on the pointer or on the stores' maps, which the race detector reported hundreds of times under load and which can crash the server with a concurrent map access. Store access now always happens under s.mu. Reads return a copy of the entry so it can be used after unlocking, and target handlers hash files outside the lock and only write the result under it.