celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [celix] 01/03: Adds "already added check" for pubsub serializerion provider.
Date Wed, 10 Jun 2020 19:05:09 GMT
This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/pubsub_utils_test_fix
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 8cd3c9fca8cb52f5320bf3bba4e96d13b5b451ca
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
AuthorDate: Wed Jun 10 21:03:25 2020 +0200

    Adds "already added check" for pubsub serializerion provider.
    
    This is to prevent possible entries added because of multiple bundle event being handled.
---
 .../src/pubsub_serialization_provider.c            | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/bundles/pubsub/pubsub_utils/src/pubsub_serialization_provider.c b/bundles/pubsub/pubsub_utils/src/pubsub_serialization_provider.c
index a0559e4..99e6d6b 100644
--- a/bundles/pubsub/pubsub_utils/src/pubsub_serialization_provider.c
+++ b/bundles/pubsub/pubsub_utils/src/pubsub_serialization_provider.c
@@ -259,6 +259,21 @@ static dyn_message_type* pubsub_serializationProvider_parseDfiDescriptor(pubsub_
 //}
 
 /**
+ * Check if a pubsub serialization entry is already present (exact path)
+ *
+ * @return true if the entry is a already present
+ */
+static bool pubsub_serializationProvider_alreadyAddedEntry(pubsub_serialization_provider_t*
provider, pubsub_serialization_entry_t* entry) {
+    for (int i = 0; i < celix_arrayList_size(provider->serializationSvcEntries); ++i)
{
+        pubsub_serialization_entry_t *visit = celix_arrayList_get(provider->serializationSvcEntries,
i);
+        if (celix_utils_stringEquals(visit->readFromEntryPath, entry->readFromEntryPath)
{
+            return true;
+        }
+    }
+    return false;
+}
+
+/**
  * Validates an pubsub serialization entry and check if this is a new unique entry.
  *
  * Checks whether the entry is valid. Specifically checks:
@@ -407,6 +422,15 @@ static void pubsub_serializationProvider_parseDescriptors(pubsub_serialization_p
         serEntry->svc.freeDeserializedMsg = (void*)provider->freeDeserializeMsg;
         serEntry->svcId = -1L;
 
+        if (pubsub_serializationProvider_alreadyAddedEntry(provider, serEntry)) {
+            L_WARN("Skipping entry %s. Exact entry already present!. Double event triggered?",
serEntry->readFromEntryPath);
+            free(serEntry->descriptorContent);
+            free(serEntry->readFromEntryPath);
+            free(serEntry->msgVersionStr);
+            dynMessage_destroy(serEntry->msgType);
+            free(serEntry);
+            continue;
+        }
 
         bool unique = pubsub_serializationProvider_validateEntry(provider, serEntry);
         if (unique && serEntry->valid) { //note only register if unique and valid


Mime
View raw message