Module: xenomai-3
Branch: wip/heap-bitmap
Commit: 12c2468c024953be7e754abea5e23fa946ec51bb
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=12c2468c024953be7e754abea5e23fa946ec51bb

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Jun  6 20:34:10 2016 +0200

copperplate/heapobj-pshared: unlink main heap file on exit if no registry

sysregd removes the shared heap upon exit of the last process attached
to the session. When no registry support is enabled, make sure the
backing file is unlinked upon exit of the main process.

---

 lib/copperplate/heapobj-pshared.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lib/copperplate/heapobj-pshared.c 
b/lib/copperplate/heapobj-pshared.c
index 43aac70..59ea88d 100644
--- a/lib/copperplate/heapobj-pshared.c
+++ b/lib/copperplate/heapobj-pshared.c
@@ -29,6 +29,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <string.h>
 #include <pthread.h>
 #include <unistd.h>
@@ -675,6 +676,19 @@ out:
        return ret;
 }
 
+#ifndef CONFIG_XENO_REGISTRY
+static void unlink_main_heap(void)
+{
+       /*
+        * Only the master process run this when there is no registry
+        * support (i.e. the one which has initialized the main shared
+        * heap for the session). When the registry is enabled,
+        * sysregd does the housekeeping.
+        */
+       shm_unlink(main_pool.fsname);
+}
+#endif
+
 static int create_main_heap(pid_t *cnode_r)
 {
        const char *session = __copperplate_setup_data.session_label;
@@ -767,6 +781,10 @@ reset:
        ret = fchown(fd, geteuid(), getegid());
        (void)ret;
 init:
+#ifndef CONFIG_XENO_REGISTRY
+       atexit(unlink_main_heap);
+#endif
+
        ret = ftruncate(fd, 0);  /* Clear all previous contents if any. */
        if (__bterrno(ret))
                goto unlink_fail;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to