We need a lock around accessing the alarms map, because the onvif thread may clear an item while we are accessing it.
parent
42914b63c0
commit
890f14860d
|
@ -341,6 +341,7 @@ class Monitor : public std::enable_shared_from_this<Monitor> {
|
|||
PullPointSubscriptionBindingProxy proxyEvent;
|
||||
void set_credentials(struct soap *soap);
|
||||
std::unordered_map<std::string, std::string> alarms;
|
||||
std::mutex alarms_mutex;
|
||||
#endif
|
||||
public:
|
||||
explicit ONVIF(Monitor *parent_);
|
||||
|
|
|
@ -187,7 +187,10 @@ void Monitor::ONVIF::WaitForMessage() {
|
|||
// Apparently simple motion events, the value is boolean, but for people detection can be things like isMotion, isPeople
|
||||
if (last_value.find("false") == 0) {
|
||||
Info("Triggered off ONVIF");
|
||||
alarms.erase(last_topic);
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(alarms_mutex);
|
||||
alarms.erase(last_topic);
|
||||
}
|
||||
Debug(1, "ONVIF Alarms Empty: Alarms count is %zu, alarmed is %s, empty is %d ", alarms.size(), alarmed ? "true": "false", alarms.empty());
|
||||
if (alarms.empty()) {
|
||||
alarmed = false;
|
||||
|
@ -285,6 +288,7 @@ int SOAP_ENV__Fault(struct soap *soap, char *faultcode, char *faultstring, char
|
|||
|
||||
void Monitor::ONVIF::SetNoteSet(Event::StringSet ¬eSet) {
|
||||
#ifdef WITH_GSOAP
|
||||
std::unique_lock<std::mutex> lck(alarms_mutex);
|
||||
if (alarms.empty()) return;
|
||||
|
||||
std::string note = "";
|
||||
|
|
Loading…
Reference in New Issue