kdb: restore proc keys after caching, fix global plugin call on CACHE_HIT
@@ -771,11 +771,17 @@ static void elektraCacheCutMeta (KDB * handle)
keyDel (parentKey);
}
-static void elektraCutProc (KeySet * ks)
+KeySet * elektraCutProc (KeySet * ks)
{
Key * parentKey = keyNew ("proc", KEY_END);
- ksDel (ksCut (ks, parentKey));
+ KeySet * ret = ksCut (ks, parentKey);
keyDel (parentKey);
+ return ret;
+}
+
+static void elektraRestoreProc (KeySet * ks, KeySet * proc)
+{
+ ksAppend (ks, proc);
}
static void elektraCacheLoad (KDB * handle, KeySet * cache, Key * parentKey, Key * initialParent ELEKTRA_UNUSED, Key * cacheParent)
@@ -817,9 +823,9 @@ static int elektraCacheLoadSplit (KDB * handle, Split * split, KeySet * ks, KeyS
if (debugGlobalPositions)
{
keySetName (parentKey, keyName (initialParent));
- elektraGlobalGet (handle, ks, parentKey, PREGETSTORAGE, INIT);
- elektraGlobalGet (handle, ks, parentKey, PREGETSTORAGE, MAXONCE);
- elektraGlobalGet (handle, ks, parentKey, PREGETSTORAGE, DEINIT);
+ elektraGlobalGet (handle, *cache, parentKey, PREGETSTORAGE, INIT);
+ elektraGlobalGet (handle, *cache, parentKey, PREGETSTORAGE, MAXONCE);
+ elektraGlobalGet (handle, *cache, parentKey, PREGETSTORAGE, DEINIT);
}
keySetName (parentKey, keyName (initialParent));
@@ -827,6 +833,7 @@ static int elektraCacheLoadSplit (KDB * handle, Split * split, KeySet * ks, KeyS
elektraGlobalGet (handle, *cache, parentKey, PROCGETSTORAGE, MAXONCE);
elektraGlobalGet (handle, *cache, parentKey, PROCGETSTORAGE, DEINIT);
+ // replace ks with cached keyset
ksRewind (*cache);
if (ks->size == 0)
{
@@ -1142,7 +1149,7 @@ cachemiss:
if (cacheData && handle->globalPlugins[POSTGETCACHE][MAXONCE])
{
splitCacheStoreState (handle, split, handle->global, cacheParent, initialParent);
- elektraCutProc (ks); // remove proc keys before caching
+ KeySet * proc = elektraCutProc (ks); // remove proc keys before caching
if (elektraGlobalSet (handle, ks, cacheParent, POSTGETCACHE, MAXONCE) != ELEKTRA_PLUGIN_STATUS_SUCCESS)
{
ELEKTRA_LOG_DEBUG ("CACHE ERROR: could not store cache");
@@ -1150,6 +1157,7 @@ cachemiss:
// if there was an error, otherwise we get erroneous cache hits
elektraCacheCutMeta (handle);
}
+ elektraRestoreProc (ks, proc);
}
else
{
