Incorrect reference count management in NameServer_detach
authorRamsey Harris <ramsey@ti.com>
Wed, 29 Apr 2015 16:25:10 +0000 (09:25 -0700)
committerRobert Tivy <rtivy@ti.com>
Thu, 30 Apr 2015 17:48:03 +0000 (10:48 -0700)
Decrement the reference count only once, it was being decremented
twice. Do this regardless of the success/failure status of the
function.

linux/src/daemon/NameServer_daemon.c

index 56b21493d94f415ed9d2a431d77e870bbe3a3513..8d3643d4765e725d146b5f2228f25088ca580775 100644 (file)
@@ -1368,6 +1368,7 @@ Int NameServer_detach(UInt16 procId)
     /* procId already validated in API layer */
     clId = procId - MultiProc_getBaseIdOfCluster();
 
     /* procId already validated in API layer */
     clId = procId - MultiProc_getBaseIdOfCluster();
 
+    /* decrement reference count regardless of outcome below */
     if (--NameServer_module->comm[clId].refCount > 0) {
         goto done;
     }
     if (--NameServer_module->comm[clId].refCount > 0) {
         goto done;
     }
@@ -1387,16 +1388,13 @@ Int NameServer_detach(UInt16 procId)
     read(NameServer_module->waitFd, &event, sizeof(event));
 
     /* close the sending socket */
     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 */
     close(sendSock);
 
     /* close the receiving socket */
-    LOG1("NameServer_destroy: closing socket: %d\n", recvSock)
+    LOG1("NameServer_detach: closing socket: %d\n", recvSock)
     close(recvSock);
 
     close(recvSock);
 
-    /* decrement the reference count */
-    NameServer_module->comm[clId].refCount--;
-
 done:
     return (status);
 }
 done:
     return (status);
 }