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-unsubscr...@celix.apache.org

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

Reply via email to