mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
fix(native): shmat fails when it cannot take the segment lock
This commit is contained in:
1 parent
fabd20b019
commit
da30812c31
1 file changed
+5
@@ -388,7 +388,12 @@ static void *shmat_locked(int shmid, const void *shmaddr, int shmflg);
|
||||
|
||||
void *shmat(int shmid, const void *shmaddr, int shmflg) {
|
||||
init_ddnatv_hook();
|
||||
// without the lock the collector could remove the segment mid-attach
|
||||
int lock = g_ddnatv_root[0] != '\0' ? shm_lock_dir(LOCK_SH) : -1;
|
||||
if (lock < 0) {
|
||||
errno = EINVAL;
|
||||
return (void *)-1;
|
||||
}
|
||||
void *addr = shmat_locked(shmid, shmaddr, shmflg);
|
||||
int saved = errno;
|
||||
shm_unlock_dir(lock);
|
||||
|
||||
Reference in new issue
Block a user