]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blobdiff - linux/src/daemon/NameServer_daemon.c
Remove NameServer instance from module list in NameServer_delete()
[ipc/ipcdev.git] / linux / src / daemon / NameServer_daemon.c
index 13a0cd0c2eec7b148352fe230782ff542f4f60a8..279bf3604b4c20d0b7cfefe492cd6397f98a047c 100644 (file)
@@ -275,16 +275,17 @@ static void NameServerRemote_processMessage(NameServerRemote_Msg *msg,
             }
         }
 
-        LOG2("NameServer Response: instanceName: %s, name: %s,",
-             (String)msg->instanceName, (String)msg->name)
         /* set the request status */
         if (status < 0) {
-            LOG1(" Value not found, status: %d\n", status)
+            LOG3("NameServer Response: instance: %s, name: %s, value not "
+                    "found, status: %d\n", (String)msg->instanceName,
+                    (String)msg->name, status);
             msg->requestStatus = 0;
         }
         else {
+            LOG3("NameServer Response: instance: %s, name: %s, value: 0x%x\n",
+                    (String)msg->instanceName, (String)msg->name, msg->value);
             msg->requestStatus = 1;
-            LOG1(" Value: 0x%x\n", msg->value)
         }
 
         /* specify message as a response */
@@ -387,9 +388,9 @@ static void *listener_cb(void *arg)
                 }
                 else {
                     LOG1("listener_cb: recvfrom socket: fd: %d\n", sock)
-                    LOG2("\tReceived ns msg: nbytes: %d, from addr: %d, ",
-                         nbytes, fromAddr.addr)
-                    LOG1("from vproc: %d\n", fromAddr.vproc_id)
+                    LOG3("\tReceived ns msg: nbytes: %d, from addr: %d, "
+                            "from vproc: %d\n", nbytes, fromAddr.addr,
+                            fromAddr.vproc_id);
                     NameServerRemote_processMessage(&msg, procId);
                 }
             }
@@ -682,6 +683,9 @@ Int NameServer_delete(NameServer_Handle *handle)
     /* destroy the mutex */
     pthread_mutex_destroy(&obj->gate);
 
+    /* remove from objList */
+    CIRCLEQ_REMOVE(&NameServer_module->objList, obj, elem);
+
     /* finally, free the instance object */
     free(obj);
 
@@ -974,9 +978,8 @@ Int NameServer_getRemote(NameServer_Handle handle,
     strncpy((char *)nsMsg.instanceName, obj->name, strlen(obj->name) + 1);
     strncpy((char *)nsMsg.name, name, strlen(name) + 1);
 
-    LOG2("NameServer_getRemote: Requesting from procId %d, %s:",
-           procId, (String)nsMsg.instanceName)
-    LOG1("%s...\n", (String)nsMsg.name)
+    LOG3("NameServer_getRemote: requesting from procId %d, %s: %s\n",
+            procId, (String)nsMsg.instanceName, (String)nsMsg.name);
 
     err = send(sock, &nsMsg, sizeof(NameServerRemote_Msg), 0);
     if (err < 0) {
@@ -1028,10 +1031,10 @@ Int NameServer_getRemote(NameServer_Handle handle,
                 /* set the contents of value */
                 if (*len <= sizeof (Bits32)) {
                     *(UInt32 *)value = (UInt32)replyMsg->value;
-                    LOG2("NameServer_getRemote: Reply from: %d, %s:",
-                        procId, (String)replyMsg->instanceName)
-                    LOG2("%s, value: 0x%x...\n",
-                        (String)replyMsg->name, *(UInt32 *)value)
+                    LOG4("NameServer_getRemote: Reply from: %d, %s: "
+                            "name: %s, value: 0x%x\n", procId,
+                            (String)replyMsg->instanceName,
+                            (String)replyMsg->name, *(UInt32 *)value);
                 }
                 else {
                     memcpy(value, replyMsg->valueBuf, *len);
@@ -1278,6 +1281,9 @@ Int NameServer_attach(UInt16 procId)
     /* procId already validated in API layer */
     clId = procId - MultiProc_getBaseIdOfCluster();
 
+    LOG2("NameServer_attach: --> procId=%d, refCount=%d\n",
+            procId, NameServer_module->comm[clId].refCount)
+
     /* must reference count because we have multiple clients */
     if (NameServer_module->comm[clId].refCount > 0) {
         NameServer_module->comm[clId].refCount++;
@@ -1351,6 +1357,9 @@ done:
         }
     }
 
+    LOG2("NameServer_attach: <-- refCount=%d, status=%d\n",
+            NameServer_module->comm[clId].refCount, status)
+
     return (status);
 }
 
@@ -1368,6 +1377,10 @@ Int NameServer_detach(UInt16 procId)
     /* procId already validated in API layer */
     clId = procId - MultiProc_getBaseIdOfCluster();
 
+    LOG2("NameServer_detach: --> procId=%d, refCount=%d\n",
+            procId, NameServer_module->comm[clId].refCount)
+
+    /* decrement reference count regardless of outcome below */
     if (--NameServer_module->comm[clId].refCount > 0) {
         goto done;
     }
@@ -1387,17 +1400,16 @@ Int NameServer_detach(UInt16 procId)
     read(NameServer_module->waitFd, &event, sizeof(event));
 
     /* close the sending socket */
-    LOG1("NameServer_destroy: closing socket: %d\n", sendSock)
+    LOG1("NameServer_detach: closing socket: %d\n", sendSock)
     close(sendSock);
 
     /* close the receiving socket */
-    LOG1("NameServer_destroy: closing socket: %d\n", recvSock)
+    LOG1("NameServer_detach: closing socket: %d\n", recvSock)
     close(recvSock);
 
-    /* decrement the reference count */
-    NameServer_module->comm[clId].refCount--;
-
 done:
+    LOG2("NameServer_detach: <-- refCount=%d, status=%d\n",
+            NameServer_module->comm[clId].refCount, status)
     return (status);
 }