diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f5ecd45..3c5d8bdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ Everything that changes for someone using Wolfram goes here, newest first, in th ## [Unreleased] +### Fixed + +- The DID document cache's TTLs are guarded by its lock rather than atomics. A 64-bit `time_t` has no lock-free atomic load on the 32-bit PowerPC Wii U, so the library failed to link there once a client resolved a DID (Cobalt's sign-in discovery). ([#191](https://github.com/ewanc26/wolfram/pull/191)) + ## [0.38.1] - 2026-10-07 ### Fixed diff --git a/src/identity/identity.c b/src/identity/identity.c index b7f186f2..69096371 100644 --- a/src/identity/identity.c +++ b/src/identity/identity.c @@ -664,14 +664,17 @@ typedef struct { static wf_did_cache_entry wf_did_cache[WF_DID_CACHE_SLOTS]; static pthread_mutex_t wf_did_cache_lock = PTHREAD_MUTEX_INITIALIZER; -static _Atomic time_t wf_did_cache_stale_ttl = 3600; /* 1h, matches ref */ -static _Atomic time_t wf_did_cache_max_ttl = 86400; /* 1d, matches ref */ +/* Guarded by wf_did_cache_lock, not atomics: a 64-bit time_t has no lock-free + * atomic load on 32-bit PowerPC (the Wii U), so __atomic_load_8 does not link. + */ +static time_t wf_did_cache_stale_ttl = 3600; /* 1h, matches ref */ +static time_t wf_did_cache_max_ttl = 86400; /* 1d, matches ref */ void wf_did_cache_configure(time_t stale_ttl_seconds, time_t max_ttl_seconds) { - atomic_store_explicit(&wf_did_cache_stale_ttl, stale_ttl_seconds, - memory_order_relaxed); - atomic_store_explicit(&wf_did_cache_max_ttl, max_ttl_seconds, - memory_order_relaxed); + pthread_mutex_lock(&wf_did_cache_lock); + wf_did_cache_stale_ttl = stale_ttl_seconds; + wf_did_cache_max_ttl = max_ttl_seconds; + pthread_mutex_unlock(&wf_did_cache_lock); } void wf_did_cache_clear(void) { @@ -736,10 +739,10 @@ static void wf_did_cache_put(const char *did, const char *json) { static wf_status did_fetch_document(wf_xrpc_client *client, const char *did, cJSON **out_root) { - time_t stale_ttl = - atomic_load_explicit(&wf_did_cache_stale_ttl, memory_order_relaxed); - time_t max_ttl = - atomic_load_explicit(&wf_did_cache_max_ttl, memory_order_relaxed); + pthread_mutex_lock(&wf_did_cache_lock); + time_t stale_ttl = wf_did_cache_stale_ttl; + time_t max_ttl = wf_did_cache_max_ttl; + pthread_mutex_unlock(&wf_did_cache_lock); if (max_ttl <= 0) return did_fetch_document_uncached(client, did, out_root);