...
 
Commits (2)
  • Aleksy Barcz's avatar
    deadlock in UDIC/UDIM fix continuation · ec8d2a29
    Aleksy Barcz authored
    + follow-up of "fixed deadlock in defined initialization"
    + previous fix fixed the deadlock in one case, but not in the general case, as unfortunately there are other call-traces that lead to the deadlock
    + this fixes a sequence, where thread 1 calls UDIM::AddUserDef (acquires mutex), which calls UDIC::AddUserDef (acquires m_lock); while thread 2 calls PCIC::GetConfig (acquires m_lock), which calls UDIC::AddConfig, which calls UDIM::PopConfig (acquires mutex)
    + the general design flaw is that UDIM can call UDIC and vice versa. This is wrong and especially bug-prone when using locks.
    + this fix should fix the general case. The design flaw remains to be fixed, but now whenever UDIM calls UDIC, it does so without holding mutex (fixed both places in code where I found such a situation). So both locks are held only on the path from UDIC to UDIM and not vice versa.
    ec8d2a29
  • Aleksy Barcz's avatar
    launch query executor after all configs are loaded · 3f3418cc
    Aleksy Barcz authored
    + launch query executor as the last step of OnInit
    + this fixes a segfault when QueryExecutor tries to SetProberAddress while OnInit didn't finish loading configurations
    + probably this worked previously only because configurations loaded fast enough
    3f3418cc
......@@ -58,15 +58,15 @@ TSzarpConfig* UserDefinedIPKManager::PopConfig(const std::wstring &prefix) {
}
void UserDefinedIPKManager::AddUserDefined(const std::wstring& prefix, TParam *param) {
boost::unique_lock<boost::shared_mutex> lock(mutex);
if (ipk->AddUserDefined(prefix, param)) {
boost::unique_lock<boost::shared_mutex> lock(mutex);
m_extra_params[prefix].emplace_back(param);
}
}
void UserDefinedIPKManager::RemoveUserDefined(const std::wstring& prefix, TParam *param) {
boost::unique_lock<boost::shared_mutex> lock(mutex);
if (ipk->RemoveUserDefined(prefix, param)) {
boost::unique_lock<boost::shared_mutex> lock(mutex);
auto& tp = m_extra_params[prefix];
auto ei = std::find_if(tp.begin(), tp.end(),
[param] (std::shared_ptr<TParam> &_p) { return _p.get() == param; }
......
......@@ -415,12 +415,6 @@ bool DrawApp::OnInit() {
m_dbmgr->SetBaseHandler(base_handler);
m_dbmgr->SetProbersAddresses(GetProbersAddresses());
splash->PushStatusText(_("Starting database query mechanism..."));
m_executor = new QueryExecutor(m_db_queue, m_dbmgr, m_dbmgr->GetBaseHandler());
m_executor->Create();
m_executor->SetPriority((WXTHREAD_MAX_PRIORITY + WXTHREAD_DEFAULT_PRIORITY) / 2);
m_executor->Run();
m_cfg_mgr->SetDatabaseManager(m_dbmgr);
......@@ -484,6 +478,12 @@ bool DrawApp::OnInit() {
return FALSE;
}
splash->PushStatusText(_("Starting database query mechanism..."));
m_executor = new QueryExecutor(m_db_queue, m_dbmgr, m_dbmgr->GetBaseHandler());
m_executor->Create();
m_executor->SetPriority((WXTHREAD_MAX_PRIORITY + WXTHREAD_DEFAULT_PRIORITY) / 2);
m_executor->Run();
wxToolTip::SetDelay(1000);
SetAppName(_T("SZARPDRAW3"));
......