You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by GitBox <gi...@apache.org> on 2020/05/06 06:28:53 UTC

[GitHub] [celix] pnoltes commented on a change in pull request #224: Fixes an potential race condition issues with the creation of service ids

pnoltes commented on a change in pull request #224:
URL: https://github.com/apache/celix/pull/224#discussion_r420569791



##########
File path: libs/framework/src/service_registry.c
##########
@@ -1215,4 +1215,9 @@ static void celix_waitForPendingRegisteredEvents(celix_service_registry_t *regis
         count = (long)hashMap_get(registry->pendingRegisterEvents.map, (void*)svcId);
     }
     celixThreadMutex_unlock(&registry->pendingRegisterEvents.mutex);
+}
+
+long celix_serviceRegistry_nextSvcId(celix_service_registry_t* registry) {
+    long scvId = __atomic_fetch_add(&registry->nextServiceId, 1, __ATOMIC_SEQ_CST);

Review comment:
       Correct. svc id 0 is a valid service id, but celix always started with 1.
   
   I will revert this. Even though svc id 0 is valid, this change can trigger some dormant issues where validity of service id are tested as svcId > 0. 
   That is also why the test where updated.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org