Skip to content

Commit

Permalink
Changes following review
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Jan 10, 2025
1 parent 5240339 commit 6c067c2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
4 changes: 2 additions & 2 deletions dali/base/dafdesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3725,9 +3725,9 @@ static CriticalSection storageCS;
static void doInitializeStorageGroups(bool createPlanesFromGroups, IPropertyTree * newGlobalConfiguration)
{
CriticalBlock block(storageCS);
Owned<IPropertyTree> storage = newGlobalConfiguration->getPropTree("storage");
IPropertyTree * storage = newGlobalConfiguration->queryPropTree("storage");
if (!storage)
storage.set(newGlobalConfiguration->addPropTree("storage"));
storage = newGlobalConfiguration->addPropTree("storage");

if (!isContainerized() && createPlanesFromGroups)
{
Expand Down
30 changes: 23 additions & 7 deletions system/jlib/jptree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8735,7 +8735,7 @@ class CConfigUpdater : public CInterface
args.append(arg);
args.append(nullptr);

refreshConfiguration(true, false);
refreshConfiguration(true, true);
}
bool startMonitoring()
{
Expand Down Expand Up @@ -8780,8 +8780,7 @@ class CConfigUpdater : public CInterface
{
CriticalBlock b(notifyFuncCS);
//Ensure all modifications to the config take place before the config is updated, and the monitoring/caching functions are called.
for (auto & modifyFunc : modifyConfigUpdates)
modifyFunc.second(newComponentConfiguration, newGlobalConfiguration);
executeModifyCallbacks(newComponentConfiguration, newGlobalConfiguration);

// NB: block calls to get*Config*() from other threads until callbacks notified and new swapped in, destroy old config outside the critical section
Owned<IPropertyTree> oldComponentConfiguration;
Expand All @@ -8800,7 +8799,7 @@ class CConfigUpdater : public CInterface

/* NB: we are still holding 'configCS' at this point, blocking all other thread access.
However code in callbacks may call e.g. getComponentConfig() and re-enter the crit */
executeCallbacks(oldComponentConfiguration, oldGlobalConfiguration);
executeNotifyCallbacks(oldComponentConfiguration, oldGlobalConfiguration);
}
}

Expand Down Expand Up @@ -8837,14 +8836,14 @@ class CConfigUpdater : public CInterface
}
}

void executeCallbacks()
void executeNotifyCallbacks()
{
CriticalBlock notifyBlock(notifyFuncCS);
CriticalBlock configBlock(configCS);
executeCallbacks(componentConfiguration, globalConfiguration);
executeNotifyCallbacks(componentConfiguration, globalConfiguration);
}

void executeCallbacks(IPropertyTree *oldComponentConfiguration, IPropertyTree *oldGlobalConfiguration)
void executeNotifyCallbacks(IPropertyTree *oldComponentConfiguration, IPropertyTree *oldGlobalConfiguration)
{
for (const auto &item: notifyConfigUpdates)
{
Expand All @@ -8859,6 +8858,23 @@ class CConfigUpdater : public CInterface
}
}
}

void executeModifyCallbacks(IPropertyTree * newComponentConfiguration, IPropertyTree * newGlobalConfiguration)
{
for (auto & modifyFunc : modifyConfigUpdates)
{
try
{
modifyFunc.second(newComponentConfiguration, newGlobalConfiguration);
}
catch (IException *e)
{
EXCLOG(e, "CConfigUpdater callback");
e->Release();
}
}
}

unsigned addNotifyFunc(ConfigUpdateFunc notifyFunc, bool callWhenInstalled)
{
CriticalBlock b(notifyFuncCS);
Expand Down

0 comments on commit 6c067c2

Please sign in to comment.