You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by "xuzhenbao (via GitHub)" <gi...@apache.org> on 2023/05/11 13:27:56 UTC

[PR] Bug fix for rsa_shm and rsa_json_rpc (celix)

xuzhenbao opened a new pull request, #551:
URL: https://github.com/apache/celix/pull/551

   1. Fix #540
   2. Improve rsa_common
   3. Replace the hash_map in rsa_json_rpc with celix_long_hash_map
   4.Resolve some code review issues


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

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

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


Re: [PR] Bug fix for rsa_shm and rsa_json_rpc (celix)

Posted by "xuzhenbao (via GitHub)" <gi...@apache.org>.
xuzhenbao commented on PR #551:
URL: https://github.com/apache/celix/pull/551#issuecomment-1560412037

   > One thing I also would like to improve is the usage of service references and service registrations in the remote service admin interfaces.
   
   Hi @pnoltes 
   Can we remove `export_reference_t` and `import_reference_t` from `remote_service_admin_service_t`, and use `serviceProperties` instead of `serviceId` or add a new framework interface that can get service properties by `serviceId`, as follows:
   ~~~
   struct remote_service_admin_service_v2 {
   	void *handle;
   	celix_status_t (*exportService)(void *handle,  celix_properties_t *serviceProperties, celix_properties_t *additionalProperties, celix_array_list_pt *registrations);
   	celix_status_t (*importService)(void *handle, endpoint_description_t *endpoint, import_registration_t **registration);
   
   	celix_status_t (*exportRegistration_getEndpointDescription)(export_registration_t *registration, endpoint_description_t **endpoint);
   
   	celix_status_t (*exportRegistration_close)(void *handle, export_registration_t *registration);
   
   	celix_status_t (*importRegistration_close)(void *handle, import_registration_t *registration);
   };
   ~~~


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

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

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


Re: [PR] Bug fix for rsa_shm and rsa_json_rpc (celix)

Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #551:
URL: https://github.com/apache/celix/pull/551#discussion_r1192052234


##########
conanfile.py:
##########
@@ -252,6 +252,8 @@ def _enable_error_injectors(self):
         for k in self.deps_cpp_info.deps:
             if k == "mdnsresponder":
                 self._cmake.definitions["BUILD_ERROR_INJECTOR_MDNSRESPONDER"] = "ON"
+        if self.options.build_celix_dfi:
+            self._cmake.definitions["BUILD_ERROR_INJECTOR_DFI"] = "ON"

Review Comment:
   We can reuse build_celix_dfi.



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

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

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


Re: [PR] Bug fix for rsa_shm and rsa_json_rpc (celix)

Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #551:
URL: https://github.com/apache/celix/pull/551#discussion_r1192955924


##########
bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_client.c:
##########
@@ -178,14 +179,8 @@ void rsaShmClientManager_destroy(rsa_shm_client_manager_t *clientManager) {
     celixThreadMutex_unlock(&clientManager->exceptionMsgListMutex);
     (void)celixThreadCondition_signal(&clientManager->exceptionMsgListNotEmpty);
     celixThread_join(clientManager->msgExceptionHandlerThread, NULL);
-    size_t listSize = celix_arrayList_size(clientManager->exceptionMsgList);
-    for (int i = 0; i < listSize; ++i) {
-        rsa_shm_exception_msg_t *exceptionMsg = celix_arrayList_get(clientManager->exceptionMsgList, i);
-        //Here,we should not free 'msgBuffer' and 'msgCtrl' by shmPool_free, because rsa_shm_server maybe using them, and tlsf_free will modify freed memory.
-        //The shared memory  of 'msgBuffer' and 'msgCtrl' will be freed automatically when nobody is using it.

Review Comment:
   I have changed my mind: the previous approach may be better.



##########
bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_client.c:
##########
@@ -630,14 +626,22 @@ static void *rsaShmClientManager_exceptionMsgHandlerThread(void *data) {
     celix_array_list_t *evictedMsgs = celix_arrayList_create();
     while (active) {
         celixThreadMutex_lock(&clientManager->exceptionMsgListMutex);
-        while (0 == (listSize = celix_arrayList_size(clientManager->exceptionMsgList)) && clientManager->threadActive == true) {
-            (void)celixThreadCondition_timedwaitRelative(&clientManager->exceptionMsgListNotEmpty, &clientManager->exceptionMsgListMutex, 0, 200*1000*1000);
-        }
+        listSize = celix_arrayList_size(clientManager->exceptionMsgList);
         for (int i = 0; i < listSize; ++i) {
             struct rsa_shm_exception_msg *exceptionMsg = celix_arrayList_get(clientManager->exceptionMsgList, i);
             removed = rsaShmClientManager_handleMsgState(clientManager, exceptionMsg);
             if (removed) {
                 celix_arrayList_add(evictedMsgs, exceptionMsg);
+            } else if (clientManager->threadActive == false) {
+                int fd = socket(AF_UNIX, SOCK_DGRAM, 0);
+                if (fd >= 0) {
+                    if (bind(fd, (struct sockaddr *) &exceptionMsg->serverAddr, sizeof(struct sockaddr_un)) == 0) {

Review Comment:
   I don't feel right. 
   Missing `pthread_cond_destroy` and `pthread_mutex_destroy` is no big deal compared to this.



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

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

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


Re: [PR] Bug fix for rsa_shm and rsa_json_rpc (celix)

Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #551:
URL: https://github.com/apache/celix/pull/551#discussion_r1192052760


##########
libs/error_injector/CMakeLists.txt:
##########
@@ -43,8 +43,13 @@ add_subdirectory(pthread)
 add_subdirectory(celix_log_helper)
 add_subdirectory(celix_bundle)
 add_subdirectory(celix_version)
-add_subdirectory(dfi)
+add_subdirectory(celix_long_hash_map)
 
+
+celix_subproject(ERROR_INJECTOR_DFI "Option to enable building the celix dfi error injector" ON)
+if (ERROR_INJECTOR_DFI)

Review Comment:
   Unnecessary option.



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

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

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


Re: [PR] Bug fix for rsa_shm and rsa_json_rpc (celix)

Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #551:
URL: https://github.com/apache/celix/pull/551#discussion_r1191197382


##########
bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_client.c:
##########
@@ -638,6 +634,16 @@ static void *rsaShmClientManager_exceptionMsgHandlerThread(void *data) {
             removed = rsaShmClientManager_handleMsgState(clientManager, exceptionMsg);
             if (removed) {
                 celix_arrayList_add(evictedMsgs, exceptionMsg);
+            } else if (clientManager->threadActive == false) {
+                int fd = socket(AF_UNIX, SOCK_DGRAM, 0);
+                if (fd >= 0) {
+                    if (bind(fd, (struct sockaddr *) &exceptionMsg->serverAddr, sizeof(struct sockaddr_un)) == 0) {
+                        //Peer server process has been terminated, so remove the exception message
+                        //If the peer server process is still running, the bind will fail, and errno will be set to EADDRINUSE
+                        celix_arrayList_add(evictedMsgs, exceptionMsg);

Review Comment:
   Busy loop when `clientManager->threadActive == false`.



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

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

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


Re: [PR] Bug fix for rsa_shm and rsa_json_rpc (celix)

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #551:
URL: https://github.com/apache/celix/pull/551#issuecomment-1545028839

   ## [Codecov](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#551](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e575ec4) into [master](https://app.codecov.io/gh/apache/celix/commit/fc18c65d66918b8223e85944b910f9c15776947b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (fc18c65) will **increase** coverage by `0.12%`.
   > The diff coverage is `100.00%`.
   
   > :exclamation: Current head e575ec4 differs from pull request most recent head c9ce507. Consider uploading reports for the commit c9ce507 to get more accurate results
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #551      +/-   ##
   ==========================================
   + Coverage   77.43%   77.56%   +0.12%     
   ==========================================
     Files         226      227       +1     
     Lines       34639    34725      +86     
   ==========================================
   + Hits        26824    26934     +110     
   + Misses       7815     7791      -24     
   ```
   
   
   | [Impacted Files](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...mote\_service\_admin\_shm\_v2/shm\_pool/src/shm\_cache.c](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnVuZGxlcy9yZW1vdGVfc2VydmljZXMvcmVtb3RlX3NlcnZpY2VfYWRtaW5fc2htX3YyL3NobV9wb29sL3NyYy9zaG1fY2FjaGUuYw==) | `98.63% <ø> (ø)` | |
   | [...emote\_service\_admin\_shm\_v2/shm\_pool/src/shm\_pool.c](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnVuZGxlcy9yZW1vdGVfc2VydmljZXMvcmVtb3RlX3NlcnZpY2VfYWRtaW5fc2htX3YyL3NobV9wb29sL3NyYy9zaG1fcG9vbC5j) | `97.22% <ø> (ø)` | |
   | [...\_service\_admin\_shm\_v2/rsa\_shm/src/rsa\_shm\_client.c](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnVuZGxlcy9yZW1vdGVfc2VydmljZXMvcmVtb3RlX3NlcnZpY2VfYWRtaW5fc2htX3YyL3JzYV9zaG0vc3JjL3JzYV9zaG1fY2xpZW50LmM=) | `94.81% <100.00%> (+2.36%)` | :arrow_up: |
   | [...n\_shm\_v2/rsa\_shm/src/rsa\_shm\_export\_registration.c](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnVuZGxlcy9yZW1vdGVfc2VydmljZXMvcmVtb3RlX3NlcnZpY2VfYWRtaW5fc2htX3YyL3JzYV9zaG0vc3JjL3JzYV9zaG1fZXhwb3J0X3JlZ2lzdHJhdGlvbi5j) | `100.00% <100.00%> (ø)` | |
   | [...te\_service\_admin\_shm\_v2/rsa\_shm/src/rsa\_shm\_impl.c](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnVuZGxlcy9yZW1vdGVfc2VydmljZXMvcmVtb3RlX3NlcnZpY2VfYWRtaW5fc2htX3YyL3JzYV9zaG0vc3JjL3JzYV9zaG1faW1wbC5j) | `96.81% <100.00%> (+0.03%)` | :arrow_up: |
   | [...\_service\_admin\_shm\_v2/rsa\_shm/src/rsa\_shm\_server.c](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnVuZGxlcy9yZW1vdGVfc2VydmljZXMvcmVtb3RlX3NlcnZpY2VfYWRtaW5fc2htX3YyL3JzYV9zaG0vc3JjL3JzYV9zaG1fc2VydmVyLmM=) | `92.57% <100.00%> (ø)` | |
   | [...ote\_services/rsa\_common/src/endpoint\_description.c](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnVuZGxlcy9yZW1vdGVfc2VydmljZXMvcnNhX2NvbW1vbi9zcmMvZW5kcG9pbnRfZGVzY3JpcHRpb24uYw==) | `100.00% <100.00%> (ø)` | |
   | [...services/rsa\_rpc\_json/src/rsa\_json\_rpc\_activator.c](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnVuZGxlcy9yZW1vdGVfc2VydmljZXMvcnNhX3JwY19qc29uL3NyYy9yc2FfanNvbl9ycGNfYWN0aXZhdG9yLmM=) | `100.00% <100.00%> (ø)` | |
   | [...ices/rsa\_rpc\_json/src/rsa\_json\_rpc\_endpoint\_impl.c](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnVuZGxlcy9yZW1vdGVfc2VydmljZXMvcnNhX3JwY19qc29uL3NyYy9yc2FfanNvbl9ycGNfZW5kcG9pbnRfaW1wbC5j) | `100.00% <100.00%> (ø)` | |
   | [...ervices/rsa\_rpc\_json/src/rsa\_json\_rpc\_proxy\_impl.c](https://app.codecov.io/gh/apache/celix/pull/551?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnVuZGxlcy9yZW1vdGVfc2VydmljZXMvcnNhX3JwY19qc29uL3NyYy9yc2FfanNvbl9ycGNfcHJveHlfaW1wbC5j) | `96.92% <100.00%> (+0.17%)` | :arrow_up: |
   
   ... and [4 files with indirect coverage changes](https://app.codecov.io/gh/apache/celix/pull/551/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


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

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

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


Re: [PR] Bug fix for rsa_shm and rsa_json_rpc (celix)

Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #551:
URL: https://github.com/apache/celix/pull/551#discussion_r1192956130


##########
bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_client.c:
##########
@@ -630,14 +626,22 @@ static void *rsaShmClientManager_exceptionMsgHandlerThread(void *data) {
     celix_array_list_t *evictedMsgs = celix_arrayList_create();
     while (active) {
         celixThreadMutex_lock(&clientManager->exceptionMsgListMutex);
-        while (0 == (listSize = celix_arrayList_size(clientManager->exceptionMsgList)) && clientManager->threadActive == true) {
-            (void)celixThreadCondition_timedwaitRelative(&clientManager->exceptionMsgListNotEmpty, &clientManager->exceptionMsgListMutex, 0, 200*1000*1000);
-        }
+        listSize = celix_arrayList_size(clientManager->exceptionMsgList);
         for (int i = 0; i < listSize; ++i) {
             struct rsa_shm_exception_msg *exceptionMsg = celix_arrayList_get(clientManager->exceptionMsgList, i);
             removed = rsaShmClientManager_handleMsgState(clientManager, exceptionMsg);
             if (removed) {
                 celix_arrayList_add(evictedMsgs, exceptionMsg);
+            } else if (clientManager->threadActive == false) {
+                int fd = socket(AF_UNIX, SOCK_DGRAM, 0);
+                if (fd >= 0) {
+                    if (bind(fd, (struct sockaddr *) &exceptionMsg->serverAddr, sizeof(struct sockaddr_un)) == 0) {

Review Comment:
   I don't feel right. 
   Missing `pthread_cond_destroy` and `pthread_mutex_destroy` is no big deal compared to this.



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

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

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


Re: [PR] Bug fix for rsa_shm and rsa_json_rpc (celix)

Posted by "xuzhenbao (via GitHub)" <gi...@apache.org>.
xuzhenbao merged PR #551:
URL: https://github.com/apache/celix/pull/551


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

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

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


Re: [PR] Bug fix for rsa_shm and rsa_json_rpc (celix)

Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #551:
URL: https://github.com/apache/celix/pull/551#discussion_r1192962350


##########
bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_client.c:
##########
@@ -178,14 +179,8 @@ void rsaShmClientManager_destroy(rsa_shm_client_manager_t *clientManager) {
     celixThreadMutex_unlock(&clientManager->exceptionMsgListMutex);
     (void)celixThreadCondition_signal(&clientManager->exceptionMsgListNotEmpty);
     celixThread_join(clientManager->msgExceptionHandlerThread, NULL);
-    size_t listSize = celix_arrayList_size(clientManager->exceptionMsgList);
-    for (int i = 0; i < listSize; ++i) {
-        rsa_shm_exception_msg_t *exceptionMsg = celix_arrayList_get(clientManager->exceptionMsgList, i);
-        //Here,we should not free 'msgBuffer' and 'msgCtrl' by shmPool_free, because rsa_shm_server maybe using them, and tlsf_free will modify freed memory.
-        //The shared memory  of 'msgBuffer' and 'msgCtrl' will be freed automatically when nobody is using it.
-        free(exceptionMsg->peerServerName);
-        free(exceptionMsg);

Review Comment:
   This should not be a bug. I have closed #540, check it for explanation. Feel free to recover the previous implementation.



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

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

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


Re: [PR] Bug fix for rsa_shm and rsa_json_rpc (celix)

Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #551:
URL: https://github.com/apache/celix/pull/551#discussion_r1192955924


##########
bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_client.c:
##########
@@ -178,14 +179,8 @@ void rsaShmClientManager_destroy(rsa_shm_client_manager_t *clientManager) {
     celixThreadMutex_unlock(&clientManager->exceptionMsgListMutex);
     (void)celixThreadCondition_signal(&clientManager->exceptionMsgListNotEmpty);
     celixThread_join(clientManager->msgExceptionHandlerThread, NULL);
-    size_t listSize = celix_arrayList_size(clientManager->exceptionMsgList);
-    for (int i = 0; i < listSize; ++i) {
-        rsa_shm_exception_msg_t *exceptionMsg = celix_arrayList_get(clientManager->exceptionMsgList, i);
-        //Here,we should not free 'msgBuffer' and 'msgCtrl' by shmPool_free, because rsa_shm_server maybe using them, and tlsf_free will modify freed memory.
-        //The shared memory  of 'msgBuffer' and 'msgCtrl' will be freed automatically when nobody is using it.

Review Comment:
   I have changed my mind: the previous approach may be better.



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

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

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


Re: [PR] Bug fix for rsa_shm and rsa_json_rpc (celix)

Posted by "pnoltes (via GitHub)" <gi...@apache.org>.
pnoltes commented on PR #551:
URL: https://github.com/apache/celix/pull/551#issuecomment-1546591538

   I also would like to review this, so please keep this PR open for at least a few more days


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

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

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