Skip to content

Commit

Permalink
mem: add a multiprocess-safe shm_available()
Browse files Browse the repository at this point in the history
new safe_shm_available() function secured with shm_lock()
  • Loading branch information
camilleoudot committed Apr 14, 2015
1 parent ebf6483 commit 51e263d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mem/shm_mem.c
Expand Up @@ -254,5 +254,13 @@ void shm_mem_destroy(void)
#endif
}

inline unsigned long safe_shm_available()
{
unsigned long ret;
shm_lock();
ret = shm_available();
shm_unlock();
return ret;
}

#endif
5 changes: 5 additions & 0 deletions mem/shm_mem.h
Expand Up @@ -312,6 +312,11 @@ do{\

#endif /* ! SHM_SAFE_MALLOC */

/* multi-process safe version of shm_available()
*/
inline unsigned long safe_shm_available();


#endif /* shm_mem_h */

#endif /* SHM_MEM */
Expand Down

0 comments on commit 51e263d

Please sign in to comment.