From f2bf897834bfa70d682480404cc2b24745da913f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 14 Jul 2021 14:16:05 +0200 Subject: [PATCH] FIX loop protectiong --- CHANGES_NEXT_RELEASE | 3 ++- src/lib/mongoBackend/MongoCommonUpdate.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index a44e554fb1..49fb0be5d9 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,2 +1,3 @@ +- Fix: extend loop protection to any request (not only custom notifications) to cover potential update loops due to CEP integration - Hardening: Improve notification pool worker thread termination logic (#3877) -- Remove: deprecated feature initial notification upon subscription creation or update \ No newline at end of file +- Remove: deprecated feature initial notification upon subscription creation or update diff --git a/src/lib/mongoBackend/MongoCommonUpdate.cpp b/src/lib/mongoBackend/MongoCommonUpdate.cpp index a3fd978f02..ba81cdb706 100644 --- a/src/lib/mongoBackend/MongoCommonUpdate.cpp +++ b/src/lib/mongoBackend/MongoCommonUpdate.cpp @@ -3101,10 +3101,10 @@ static unsigned int updateEntity notifyCerP->entity.creDate = r.hasField(ENT_CREATION_DATE) ? getNumberFieldF(r, ENT_CREATION_DATE) : -1; notifyCerP->entity.modDate = r.hasField(ENT_MODIFICATION_DATE) ? getNumberFieldF(r, ENT_MODIFICATION_DATE) : -1; - // The logic to detect notification loops is to check that the correlator in the request differs from the last one seen for the entity and, - // in addition, the request was sent due to a custom notification + // The logic to detect notification loops is to check that the correlator in the request differs from the last one seen for the entity + // (for any kind of request, not only forged by custom notification, e.g. CEP rule) bool loopDetected = false; - if ((ngsiV2AttrsFormat == "custom") && (r.hasField(ENT_LAST_CORRELATOR))) + if (r.hasField(ENT_LAST_CORRELATOR)) { loopDetected = (getStringFieldF(r, ENT_LAST_CORRELATOR) == correlatorRoot(fiwareCorrelator)); }