| | |
| | | if(shmctl(shmid, IPC_STAT, &shmid_ds) == 0) { |
| | | //LoggerFactory::getLogger()->debug("shm_nattch=%d\n", shmid_ds.shm_nattch); |
| | | // 只有当前一个进程attach到共享内存上 |
| | | if(shmid_ds.shm_nattch == 1) { |
| | | if (shmid_ds.shm_nattch > 1) { |
| | | //detache |
| | | if (shmdt(shmp) == -1) { |
| | | LoggerFactory::getLogger()->error(errno, "mm_destroy shmdt"); |
| | | } |
| | | SemUtil::inc(mutex); |
| | | return false; |
| | | } else { |
| | | |
| | | hashtable_destroy(hashtable); |
| | | //detache |
| | |
| | | else |
| | | LoggerFactory::getLogger()->debug("shared memory destroy\n"); |
| | | |
| | | LoggerFactory::getLogger()->debug(errno, "mm_destroy: real destroy."); |
| | | |
| | | SemUtil::inc(mutex); |
| | | SemUtil::remove(mutex); |
| | | return true; |
| | | |
| | | } else { |
| | | SemUtil::inc(mutex); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | err_msg(errno, "mm_destroy shmctl IPC_STAT"); |