/** * Locks the product-index map for writing and blocks most signals. Calls * `blockSigs()`. * * @pre {`fd` is open and `pathname` is set} * @retval 0 Success. * @retval LDM7_SYSTEM System error. `log_add()` called. */ static Ldm7Status lockMapAndBlockSignals(void) { int status = lockMap(true); if (0 == status) blockSigs(); return status; }
NetCache *NetHandler::getCacheFromFd(int fd) { NetCache* cache = NULL; lockMap(); map<int, NetCache*>::const_iterator it = fdCache.find(fd); if (it != fdCache.end()) { cache = it->second; } unlockMap(); return cache; }
void NetHandler::removeConnection(int fd) { NetCache *cache = getCacheFromFd(fd); if (cache != NULL) { //int64 id = cache->uid; lockMap(); fdCache.erase(fd); unlockMap(); delete cache; } }
bool CGitIgnoreList::CheckAndUpdateCoreExcludefile(const CString &adminDir) { CString projectConfig = adminDir + _T("config"); CString globalConfig = g_Git.GetGitGlobalConfig(); CString globalXDGConfig = g_Git.GetGitGlobalXDGConfig(); CAutoWriteLock lock(m_coreExcludefilesSharedMutex); bool hasChanged = CheckAndUpdateGitSystemConfigPath(); hasChanged = hasChanged || CheckFileChanged(projectConfig); hasChanged = hasChanged || CheckFileChanged(globalConfig); hasChanged = hasChanged || CheckFileChanged(globalXDGConfig); if (!m_sGitSystemConfigPath.IsEmpty()) hasChanged = hasChanged || CheckFileChanged(m_sGitSystemConfigPath); CString excludesFile; { CAutoReadLock lock2(m_SharedMutex); excludesFile = m_CoreExcludesfiles[adminDir]; } if (!excludesFile.IsEmpty()) hasChanged = hasChanged || CheckFileChanged(excludesFile); if (!hasChanged) return false; CAutoConfig config(true); git_config_add_file_ondisk(config, CGit::GetGitPathStringA(projectConfig), GIT_CONFIG_LEVEL_LOCAL, FALSE); git_config_add_file_ondisk(config, CGit::GetGitPathStringA(globalConfig), GIT_CONFIG_LEVEL_GLOBAL, FALSE); git_config_add_file_ondisk(config, CGit::GetGitPathStringA(globalXDGConfig), GIT_CONFIG_LEVEL_XDG, FALSE); if (!m_sGitSystemConfigPath.IsEmpty()) git_config_add_file_ondisk(config, CGit::GetGitPathStringA(m_sGitSystemConfigPath), GIT_CONFIG_LEVEL_SYSTEM, FALSE); config.GetString(_T("core.excludesfile"), excludesFile); if (excludesFile.IsEmpty()) excludesFile = GetWindowsHome() + _T("\\.config\\git\\ignore"); else if (excludesFile.Find(_T("~/")) == 0) excludesFile = GetWindowsHome() + excludesFile.Mid(1); CAutoWriteLock lockMap(m_SharedMutex); g_Git.GetFileModifyTime(projectConfig, &m_Map[projectConfig].m_LastModifyTime); g_Git.GetFileModifyTime(globalXDGConfig, &m_Map[globalXDGConfig].m_LastModifyTime); if (m_Map[globalXDGConfig].m_LastModifyTime == 0) m_Map.erase(globalXDGConfig); g_Git.GetFileModifyTime(globalConfig, &m_Map[globalConfig].m_LastModifyTime); if (m_Map[globalConfig].m_LastModifyTime == 0) m_Map.erase(globalConfig); if (!m_sGitSystemConfigPath.IsEmpty()) g_Git.GetFileModifyTime(m_sGitSystemConfigPath, &m_Map[m_sGitSystemConfigPath].m_LastModifyTime); if (m_Map[m_sGitSystemConfigPath].m_LastModifyTime == 0 || m_sGitSystemConfigPath.IsEmpty()) m_Map.erase(m_sGitSystemConfigPath); m_CoreExcludesfiles[adminDir] = excludesFile; return true; }
NetCache *NetHandler::addConnection(int fd, struct sockaddr_in addr, size_t rsize) { NetCache *cache = new NetCache(fd, addr, rsize); lockMap(); fdCache.insert(pair<int, NetCache*>(fd, cache)); unlockMap(); #ifdef _WIN32 if (fd > fdmax) { fdmax = fd; } #endif return cache; }
/*! \brief. */ void MapTool::activateProject(bool active) { active_ = active; // Enable/Disable // // opacityComboBox_->setEnabled(active_); loadMapAction_->setEnabled(active_); deleteMapAction_->setEnabled(active_); lockMapAction_->setEnabled(active_); // xLineEdit_->setEnabled(active_); // yLineEdit_->setEnabled(active_); // widthLineEdit_->setEnabled(active_); // heightLineEdit_->setEnabled(active_); // Rulers // // lockMap(lockMapAction_->isChecked()); // it would be better to get the project's value somehow! }
bool CGitIgnoreList::CheckAndUpdateCoreExcludefile(const CString &adminDir) { CString projectConfig = adminDir + _T("config"); CString globalConfig = g_Git.GetGitGlobalConfig(); CString globalXDGConfig = g_Git.GetGitGlobalXDGConfig(); CAutoWriteLock lock(&m_coreExcludefilesSharedMutex); bool hasChanged = CheckAndUpdateMsysGitBinpath(); CString systemConfig = m_sMsysGitBinPath + _T("\\..\\etc\\gitconfig"); hasChanged = hasChanged || CheckFileChanged(projectConfig); hasChanged = hasChanged || CheckFileChanged(globalConfig); hasChanged = hasChanged || CheckFileChanged(globalXDGConfig); if (!m_sMsysGitBinPath.IsEmpty()) hasChanged = hasChanged || CheckFileChanged(systemConfig); m_SharedMutex.AcquireShared(); CString excludesFile = m_CoreExcludesfiles[adminDir]; m_SharedMutex.ReleaseShared(); if (!excludesFile.IsEmpty()) hasChanged = hasChanged || CheckFileChanged(excludesFile); if (!hasChanged) return false; git_config * config; git_config_new(&config); git_config_add_file_ondisk(config, CGit::GetGitPathStringA(projectConfig), GIT_CONFIG_LEVEL_LOCAL, FALSE); git_config_add_file_ondisk(config, CGit::GetGitPathStringA(globalConfig), GIT_CONFIG_LEVEL_GLOBAL, FALSE); git_config_add_file_ondisk(config, CGit::GetGitPathStringA(globalXDGConfig), GIT_CONFIG_LEVEL_XDG, FALSE); if (!m_sMsysGitBinPath.IsEmpty()) git_config_add_file_ondisk(config, CGit::GetGitPathStringA(systemConfig), GIT_CONFIG_LEVEL_SYSTEM, FALSE); const char * out = NULL; CStringA name(_T("core.excludesfile")); git_config_get_string(&out, config, name); CStringA excludesFileA(out); excludesFile = CUnicodeUtils::GetUnicode(excludesFileA); if (excludesFile.IsEmpty()) excludesFile = GetWindowsHome() + _T("\\.config\\git\\ignore"); else if (excludesFile.Find(_T("~/")) == 0) excludesFile = GetWindowsHome() + excludesFile.Mid(1); git_config_free(config); CAutoWriteLock lockMap(&m_SharedMutex); g_Git.GetFileModifyTime(projectConfig, &m_Map[projectConfig].m_LastModifyTime); g_Git.GetFileModifyTime(globalXDGConfig, &m_Map[globalXDGConfig].m_LastModifyTime); if (m_Map[globalXDGConfig].m_LastModifyTime == 0) { m_Map[globalXDGConfig].m_SharedMutex.Release(); m_Map.erase(globalXDGConfig); } g_Git.GetFileModifyTime(globalConfig, &m_Map[globalConfig].m_LastModifyTime); if (m_Map[globalConfig].m_LastModifyTime == 0) { m_Map[globalConfig].m_SharedMutex.Release(); m_Map.erase(globalConfig); } if (!m_sMsysGitBinPath.IsEmpty()) g_Git.GetFileModifyTime(systemConfig, &m_Map[systemConfig].m_LastModifyTime); if (m_Map[systemConfig].m_LastModifyTime == 0 || m_sMsysGitBinPath.IsEmpty()) { m_Map[systemConfig].m_SharedMutex.Release(); m_Map.erase(systemConfig); } m_CoreExcludesfiles[adminDir] = excludesFile; return true; }