Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/store.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ tryGetBackend(struct LDStore *const store, const char *const kind,
const char *const key, struct LDJSONRC **const result)
{
struct LDStoreCollectionItem collectionItem;
bool status;

LD_ASSERT(store);
LD_ASSERT(kind);
Expand Down Expand Up @@ -921,7 +922,11 @@ tryGetBackend(struct LDStore *const store, const char *const kind,
}

if (LDi_isFeatureDeleted(deserialized)) {
return upsertMemory(store, kind, deserialized);
LDi_rwlock_wrlock(&store->cache->lock);
status = upsertMemory(store, kind, deserialized);
LDi_rwlock_wrunlock(&store->cache->lock);

return status;
} else {
if (!(deserializedRef = LDJSONRCNew(deserialized))) {
LDJSONFree(deserialized);
Expand All @@ -937,10 +942,13 @@ tryGetBackend(struct LDStore *const store, const char *const kind,

*result = deserializedRef;

return upsertMemory(store, kind, dupe);
LDi_rwlock_wrlock(&store->cache->lock);
status = upsertMemory(store, kind, dupe);
LDi_rwlock_wrunlock(&store->cache->lock);

return status;
}
} else {
bool status;
struct LDJSON *placeholder;

LD_ASSERT(store->cache);
Expand Down