I'm using a simple pthreads process-shared mutex in a shared memory segment to coordinate multiple server instances.
Code is straightforward:
On startup server attaches to shared memory segment if it exists, or creates it if it doesn't:
shm_open()
, mmap(MAP_SHARED)
etc.
This works very well while testing, but once deployed after a while i come across cases where server instances don't coordinate at all. I can replicate this by deleting the shared memory segment after a server has started: future servers instances will create/use a new segment but the existing one is stuck with the old segment nobody uses so in effect it's isolated from the rest ...
So my guess is the shared memory segment in /dev/shm is getting deleted somehow, and not by me. This is the only thing that makes sense... What is going on here ??
Running debian with linux 4.9.