Module: xenomai-3
Branch: next
Commit: 68791e3bdc3e947fe4b846565861155cf36c0f9e
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=68791e3bdc3e947fe4b846565861155cf36c0f9e

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed May 13 11:24:52 2015 +0200

copperplate/registry: restore --shared-registry option

---

 include/copperplate/tunables.h |   11 +++++++++++
 lib/copperplate/init.c         |   11 +++++++++++
 lib/copperplate/registry.c     |   16 +++++++++-------
 3 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/include/copperplate/tunables.h b/include/copperplate/tunables.h
index be697da..8428716 100644
--- a/include/copperplate/tunables.h
+++ b/include/copperplate/tunables.h
@@ -25,6 +25,7 @@ struct copperplate_setup_data {
        const char *session_label;
        const char *registry_root;
        int no_registry;
+       int shared_registry;
        size_t mem_pool;
 };
 
@@ -64,6 +65,16 @@ static inline read_config_tunable(no_registry, int)
        return __copperplate_setup_data.no_registry;
 }
 
+static inline define_config_tunable(shared_registry, int, shared)
+{
+       __copperplate_setup_data.shared_registry = shared;
+}
+
+static inline read_config_tunable(shared_registry, int)
+{
+       return __copperplate_setup_data.shared_registry;
+}
+
 static inline define_config_tunable(mem_pool_size, size_t, size)
 {
        __copperplate_setup_data.mem_pool = size;
diff --git a/lib/copperplate/init.c b/lib/copperplate/init.c
index 08e6a20..c84d8a2 100644
--- a/lib/copperplate/init.c
+++ b/lib/copperplate/init.c
@@ -67,6 +67,12 @@ static const struct option copperplate_options[] = {
                .has_arg = 1,
        },
        {
+#define shared_registry_opt    4
+               .name = "shared-registry",
+               .flag = &__copperplate_setup_data.shared_registry,
+               .val = 1,
+       },
+       {
                /* sentinel */
        }
 };
@@ -132,6 +138,9 @@ static int get_session_root(int *regflags_r)
 
        __copperplate_setup_data.session_root = sessdir;
 
+       if (__copperplate_setup_data.shared_registry)
+               *regflags_r |= REGISTRY_SHARED;
+
        return 0;
 }
 
@@ -194,6 +203,7 @@ static int copperplate_parse_option(int optnum, const char 
*optarg)
        case regroot_opt:
                __copperplate_setup_data.registry_root = strdup(optarg);
                break;
+       case shared_registry_opt:
        case no_registry_opt:
                break;
        default:
@@ -208,6 +218,7 @@ static void copperplate_help(void)
 {
        fprintf(stderr, "--mem-pool-size=<sizeK>        size of the main heap 
(kbytes)\n");
         fprintf(stderr, "--no-registry                 suppress object 
registration\n");
+        fprintf(stderr, "--shared-registry             enable public access to 
registry\n");
         fprintf(stderr, "--registry-root=<path>                root path of 
registry\n");
         fprintf(stderr, "--session=<label>             label of shared 
multi-processing session\n");
 }
diff --git a/lib/copperplate/registry.c b/lib/copperplate/registry.c
index fb8315e..f123ee9 100644
--- a/lib/copperplate/registry.c
+++ b/lib/copperplate/registry.c
@@ -628,9 +628,9 @@ static void sigchld_handler(int sig)
 static int spawn_daemon(const char *sessdir, int flags)
 {
        struct sigaction sa;
-       char *path, *av[6];
+       char *path, *av[7];
+       int ret, n = 0;
        pid_t pid;
-       int ret;
 
        ret = asprintf(&path, "%s/sbin/sysregd", CONFIG_XENO_PREFIX);
        if (ret < 0)
@@ -659,11 +659,13 @@ static int spawn_daemon(const char *sessdir, int flags)
        av[1] = "--daemon";
        av[2] = "--root";
        av[3] = (char *)sessdir;
-       if (flags & REGISTRY_ANON) {
-               av[4] = "--anon";
-               av[5] = NULL;
-       } else
-               av[4] = NULL;
+       n = 4;
+       if (flags & REGISTRY_ANON)
+               av[n++] = "--anon";
+       if (flags & REGISTRY_SHARED)
+               av[n++] = "--shared";
+
+       av[n] = NULL;
 
        pid = vfork();
        switch (pid) {


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

Reply via email to