fix: 共享内存问题修复

Signed-off-by: Haryslee <lihao189@huawei.com>
背景:父进程移除共享内存并标记SHM_SEG_REMOVE,当子进程资源回收时在
ShmFindSeg接口中判断该共享内存具有SHM_SEG_REMOVE时返回空,但是此时
seg->ds.shm_nattch不为0,不应返回空。
方案:ShmFindSeg接口中增加seg->ds.shm_nattch为0的判断。

close #I47X2Z

Change-Id: I8735cd11ac237b17fa745c50313da0fd0649bb9f
This commit is contained in:
Haryslee 2021-09-23 21:04:36 +08:00
parent 93e74c5f0b
commit 9fdb80f85f
1 changed files with 1 additions and 1 deletions

View File

@ -304,7 +304,7 @@ STATIC struct shmIDSource *ShmFindSeg(int shmid)
} }
seg = &g_shmSegs[shmid]; seg = &g_shmSegs[shmid];
if ((seg->status & SHM_SEG_FREE) || (seg->status & SHM_SEG_REMOVE)) { if ((seg->status & SHM_SEG_FREE) || ((seg->ds.shm_nattch == 0) && (seg->status & SHM_SEG_REMOVE))) {
set_errno(EIDRM); set_errno(EIDRM);
return NULL; return NULL;
} }