bool DVBStreamHandler::RemovePIDFilter(uint pid) { #ifdef DEBUG_PID_FILTERS VERBOSE(VB_RECORD, LOC + QString("RemovePIDFilter(0x%1)").arg(pid, 0, 16)); #endif // DEBUG_PID_FILTERS QMutexLocker write_locker(&_pid_lock); PIDInfoMap::iterator it = _pid_info.find(pid); if (it == _pid_info.end()) return false; PIDInfo *tmp = *it; _pid_info.erase(it); bool ok = true; if (tmp->IsOpen()) { ok = tmp->Close(_dvb_dev); _open_pid_filters--; CycleFiltersByPriority(); } delete tmp; return ok; }
/* \brief * register crash handler with the system. * * \author * Florian Schaper <*****@*****.**> * Radu Racariu <*****@*****.**> */ void DumpHandler::register_handler(string paloIniPath) { WriteLocker write_locker(&m_lock); if (!m_enable) { return; } if (!m_initialized) { m_initialized = true; char buff[MAX_PATH]; string exePath; if (GetModuleFileName(NULL, buff, MAX_PATH)) { string::size_type pos = string(buff).find_last_of("\\/"); if (pos != string::npos) { exePath = string(buff).substr(0, pos) + '\\'; } } // initialize the singleton object if not already done so. crash_dump_manager& cdm = crash_dump_manager::get_instance(); // configure the report handling in the event of a crash // - file to be created // - program to be executed in the event of an crash. cdm.set_palo_binary_path(exePath); cdm.set_crash_report_system_call("crash_report.exe \"%1%\" \"" + Server::getVersionRevisionDots() + "\""); cdm.set_crash_dump_file("crash_%1%"); m_palo_ini = paloIniPath; cdm.set_palo_ini(paloIniPath); } SetUnhandledExceptionFilter(create_crash_dump); }
bool HDHRStreamHandler::RemoveAllPIDFilters(void) { QMutexLocker write_locker(&_pid_lock); #ifdef DEBUG_PID_FILTERS VERBOSE(VB_RECORD, LOC + "RemoveAllPIDFilters()"); #endif // DEBUG_PID_FILTERS _pid_info.clear(); return UpdateFilters(); }
void MatrixManager::process_timeo() { ::sailor::WriteLocker write_locker(&_instance_lock); for (std::map<std::string, Instance*>::iterator iter = _instance_list.begin(); iter != _instance_list.end(); ++ iter) { Instance* slot = iter->second; if (slot->check_timeo()) { _executor.stop(slot->get_generation()); } } }
bool DVBStreamHandler::RemoveAllPIDFilters(void) { QMutexLocker write_locker(&_pid_lock); #ifdef DEBUG_PID_FILTERS VERBOSE(VB_RECORD, LOC + "RemoveAllPIDFilters()"); #endif // DEBUG_PID_FILTERS vector<int> del_pids; PIDInfoMap::iterator it = _pid_info.begin(); for (; it != _pid_info.end(); ++it) del_pids.push_back(it.key()); bool ok = true; vector<int>::iterator dit = del_pids.begin(); for (; dit != del_pids.end(); ++dit) ok &= RemovePIDFilter(*dit); return ok; }
bool HDHRStreamHandler::RemovePIDFilter(uint pid, bool do_update) { #ifdef DEBUG_PID_FILTERS VERBOSE(VB_RECORD, LOC + QString("RemovePIDFilter(0x%1)").arg(pid, 0, 16)); #endif // DEBUG_PID_FILTERS QMutexLocker write_locker(&_pid_lock); vector<uint>::iterator it; it = lower_bound(_pid_info.begin(), _pid_info.end(), pid); if ((it == _pid_info.end()) || (*it != pid)) return false; _pid_info.erase(it); if (do_update) return UpdateFilters(); return true; }
/** * @brief process instance from actual to expect. * expect actual action * yes no Install * yes yes same Nothing * yes yes no-same Update * no yes remove */ void MatrixManager::process_instance_expect() { if (!_host_info.is_ready()) { LOG.info("HostInfo is INVALID, ignore processing"); return; } if (_expect_list == NULL) { LOG.info("No EXPECT received. ignore processing"); return; } ::sailor::ReadLocker read_locker(&_expect_lock); ::sailor::WriteLocker write_locker(&_instance_lock); // generate tmp_instance_list, to find diff between _expect_list and _instance_list. std::map<std::string, Instance *> tmp_instace_list(_instance_list); for (std::vector<InstanceInfo>::iterator expect = _expect_list->begin(); expect != _expect_list->end(); ++ expect) { std::map<std::string, Instance *>::iterator iter = _instance_list.find(expect->get_instance_name()); if (iter == _instance_list.end()) { // not in local InstanceMeta meta = expect->get_instance_meta(); // has enough resource if (!_host_info.has_enough_resource(meta._resource)) { LOG.warn("MatrixManager: no enough resource or for instance[%s], \nneed resource: %s, \nhost info: %s", expect->get_instance_name().c_str(), meta._resource.to_json().toStyledString().c_str(), _host_info.to_json().toStyledString().c_str()); continue; } Instance * slot = new Instance(_current_generation, expect->get_service_name(), expect->get_offset()); // do state transformation if (!slot->do_install(meta)) { LOG.warn("MatrixManager: ignore install"); delete slot; continue; } _instance_list.insert(std::pair<std::string, Instance *>(expect->get_instance_name(), slot)); _host_info.use_resource(expect->get_instance_meta()._resource); ++ _current_generation; // call executor to install _executor.install(slot->get_instance_info(), slot->get_generation()); LOG.trace("MatrixManager: add new Instance [%s] success.", slot->get_instance_info().get_instance_name().c_str()); } else { // instance is already in local tmp_instace_list.erase(expect->get_instance_name()); Instance * slot = iter->second; const InstanceInfo& instance_info = slot->get_instance_info(); if (instance_info.get_meta_version() == expect->get_meta_version()) { // local and expect is same, ignore it. continue; } // local and expect is not same, update it. if (!slot->do_update(expect->get_instance_meta())) { LOG.info("MatrixManager: ignore update of instance %s.", iter->first.c_str()); continue; } // call executor to do update. _executor.update(slot->get_instance_info(), slot->get_generation()); LOG.trace("MatrixManager: update Instance [%s] success.", slot->get_instance_info().get_instance_name().c_str()); } } // find instances that in local but not in expect. and then remove it. for (std::map<std::string, Instance *>::iterator iter = tmp_instace_list.begin(); iter != tmp_instace_list.end(); ++ iter) { Instance * slot = iter->second; if (!slot->do_remove()) { continue; } _executor.remove(slot->get_instance_info(), slot->get_generation()); LOG.trace("MatrixManager: remove Instance [%s] success.", slot->get_instance_info().get_instance_name().c_str()); } }