修复告警

Signed-off-by: zhutianyi <zhutianyi2@huawei.com>
This commit is contained in:
zhutianyi
2022-07-13 14:20:22 +08:00
parent 485b26bd25
commit 304f67f0d2
2 changed files with 10 additions and 15 deletions
+1
View File
@@ -93,6 +93,7 @@ private:
std::chrono::steady_clock::time_point ConvertToElapsed(std::chrono::milliseconds when, int type);
std::chrono::steady_clock::time_point GetBootTimeNs();
void CallbackAlarmIfNeed(std::shared_ptr<TimerInfo> alarm);
bool StopTimerInner(uint64_t timerNumber, bool needDestroy);
void RemoveProxy(uint64_t timerNumber, int32_t uid);
std::map<uint64_t, std::shared_ptr<TimerEntry>> timerEntryMap_;
+9 -15
View File
@@ -126,23 +126,15 @@ bool TimerManager::StartTimer(uint64_t timerNumber, uint64_t triggerTime)
bool TimerManager::StopTimer(uint64_t timerNumber)
{
TIME_HILOGD(TIME_MODULE_SERVICE, "start.");
std::lock_guard<std::mutex> lock(entryMapMutex_);
auto it = timerEntryMap_.find(timerNumber);
if (it == timerEntryMap_.end()) {
TIME_HILOGD(TIME_MODULE_SERVICE, "end.");
return false;
}
RemoveHandler(timerNumber);
if (it->second) {
int32_t uid = it->second->uid;
RemoveProxy(timerNumber, uid);
}
TIME_HILOGD(TIME_MODULE_SERVICE, "end.");
return true;
return StopTimerInner(timerNumber, false);
}
bool TimerManager::DestroyTimer(uint64_t timerNumber)
{
return StopTimerInner(timerNumber, true);
}
bool TimerManager::StopTimerInner(uint64_t timerNumber, bool needDestroy)
{
TIME_HILOGD(TIME_MODULE_SERVICE, "start id: %{public}" PRId64 "", timerNumber);
std::lock_guard<std::mutex> lock(entryMapMutex_);
@@ -156,7 +148,9 @@ bool TimerManager::DestroyTimer(uint64_t timerNumber)
int32_t uid = it->second->uid;
RemoveProxy(timerNumber, uid);
}
timerEntryMap_.erase(it);
if (needDestroy) {
timerEntryMap_.erase(it);
}
TIME_HILOGD(TIME_MODULE_SERVICE, "end.");
return true;
}