summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
40930da)
Leak at most a single shm if an application crashes. By unlinking the
shm before every open attempt, we are certain to never retry endlessly
in case of crash of another application between the open and unlink.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
* We specifically do _not_ use the / at the beginning of the
* pathname so that some OS implementations can keep it local to
* the process (POSIX leaves this implementation-defined).
* We specifically do _not_ use the / at the beginning of the
* pathname so that some OS implementations can keep it local to
* the process (POSIX leaves this implementation-defined).
+ * Ignore the shm_unlink errors, because we handle leaks that
+ * could occur by applications crashing between shm_open and
+ * shm_unlink by unlinking the shm before every open. Therefore,
+ * we can only leak one single shm (and only if the application
+ * crashes between shm_open and the following shm_unlink).
+ (void) shm_unlink("ust-shm-tmp");
shmfd = shm_open("ust-shm-tmp",
O_CREAT | O_EXCL | O_RDWR, 0700);
} while (shmfd < 0 && errno == EEXIST);
shmfd = shm_open("ust-shm-tmp",
O_CREAT | O_EXCL | O_RDWR, 0700);
} while (shmfd < 0 && errno == EEXIST);