修复TC_Shm类,先detch后无法del的问题

This commit is contained in:
xigua 2022-07-20 16:54:32 +08:00
parent f0c6e5a651
commit 2070c97dc1
2 changed files with 4 additions and 4 deletions

View File

@ -68,7 +68,7 @@ public:
* *
* @param bOwner ,false * @param bOwner ,false
*/ */
TC_Shm(bool bOwner = false) : _bOwner(bOwner),_shmSize(0),_shmKey(0),_bCreate(true), _pshm(NULL) {} TC_Shm(bool bOwner = false) : _bOwner(bOwner),_shmSize(0),_shmKey(0),_bCreate(true), _pshm(NULL), _shemID(0) {}
/** /**
* @brief . * @brief .
@ -181,4 +181,4 @@ protected:
} }
#endif #endif

View File

@ -120,11 +120,11 @@ int TC_Shm::del()
return 0; return 0;
#else #else
int iRetCode = 0; int iRetCode = 0;
if (_pshm != NULL) if (_shemID > 0)
{ {
iRetCode = shmctl(_shemID, IPC_RMID, 0); iRetCode = shmctl(_shemID, IPC_RMID, 0);
_pshm = NULL; _shemID = 0;
} }
return iRetCode; return iRetCode;