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/05 12:26:30 UTC

[GitHub] [celix] pnoltes opened a new pull request #224: Fixes an potential race conditation issues with the creation of servi…

pnoltes opened a new pull request #224:
URL: https://github.com/apache/celix/pull/224


   Fixes an potential race condition issue in service id creation


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
abroekhuis commented on a change in pull request #224:
URL: https://github.com/apache/celix/pull/224#discussion_r420561681



##########
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:
       If I am right, this return 0. "These built-in functions perform the operation suggested by the name, and return the value that had previously been in *ptr".
   So now instead of starting at 1, we start at 0? I don't think this introduces some error, just curious.




----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
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



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

Posted by GitBox <gi...@apache.org>.
Oipo commented on pull request #224:
URL: https://github.com/apache/celix/pull/224#issuecomment-624154574


   LGTM


----------------------------------------------------------------
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