osaf/libs/core/leap/os_defs.c                        |  4 ++--
 osaf/services/infrastructure/nid/scripts/opensafd.in |  9 +++------
 2 files changed, 5 insertions(+), 8 deletions(-)


OpenSAF fails to start on systems with (e)glibc version 2.19, e.g. Ubuntu 
14.04, openSUSE 13.2:

Error messages produced by the MSG service:
May 21 13:17:49 SC-1 local0.crit osafmsgnd[536]: CR Creation of shared memory 
segment failed
May 21 13:17:49 SC-1 local0.crit osafmsgnd[536]: CR Destroying the shared 
memory segment failed
May 21 13:17:49 SC-1 local0.err osafmsgnd[536]: ER saAmfComponentUnregister 
Failed with error 7
May 21 13:17:49 SC-1 local0.err osafmsgnd[536]: ER Either library 
initialization or destroy failed
May 21 13:17:49 SC-1 local0.err osafmsgnd[536]: __init_mqnd() failed
May 21 13:17:59 SC-1 local0.notice osafamfnd[454]: NO Instantiation of 
'safComp=MQND,safSu=SC-1,safSg=NoRed,safApp=OpenSAF' failed
May 21 13:17:59 SC-1 local0.notice osafamfnd[454]: NO Reason: component 
registration timer expired
May 21 13:17:59 SC-1 local0.warn osafamfnd[454]: WA 
'safComp=MQND,safSu=SC-1,safSg=NoRed,safApp=OpenSAF' Presence State 
INSTANTIATING => INSTANTIATION_FAILED
May 21 13:17:59 SC-1 local0.err osafamfnd[454]: ER 
'safComp=MQND,safSu=SC-1,safSg=NoRed,safApp=OpenSAF'got Inst failed
May 21 13:17:59 SC-1 local0.crit osafamfnd[454]: Rebooting OpenSAF NodeId = 
131343 EE Name = , Reason: NCS component Instantiation failed, OwnNodeId = 
131343, SupervisionTime = 60

Error messages produced by the CPKT service:
May 21 13:12:18 SC-1 local0.notice osafckptnd[496]: Started
May 21 13:12:19 SC-1 local0.err osafckptnd[496]: ER cpnd open request fail for 
RDWR mode (null)

Error messages produced by the LCK service:
May 21 13:12:56 SC-1 local0.crit osaflcknd[671]: CR GLND  shm create failure: 
rc 2 Error Invalid argument
May 21 13:12:56 SC-1 local0.notice osafamfnd[457]: NO 
'safComp=GLND,safSu=SC-1,safSg=NoRed,safApp=OpenSAF' faulted due to 'avaDown' : 
Recovery is 'componentRestart'
May 21 13:12:58 SC-1 local0.notice osaflcknd[684]: Started
May 21 13:12:58 SC-1 local0.crit osaflcknd[684]: CR GLND  shm create failure: 
rc 2 Error Invalid argument
May 21 13:12:58 SC-1 local0.notice osafamfnd[457]: NO 
'safComp=GLND,safSu=SC-1,safSg=NoRed,safApp=OpenSAF' faulted due to 'avaDown' : 
Recovery is 'suFailover'
May 21 13:12:58 SC-1 local0.err osafamfnd[457]: ER 
safComp=GLND,safSu=SC-1,safSg=NoRed,safApp=OpenSAF Faulted due to:avaDown 
Recovery is:suFailover
May 21 13:12:58 SC-1 local0.crit osafamfnd[457]: Rebooting OpenSAF NodeId = 
131343 EE Name = , Reason: Component faulted: recovery is node failfast, 
OwnNodeId = 131343, SupervisionTime = 60

The POSIX function shm_open() says that the name of a shared memory segment
shall begin with a slash, followed by up to 254 characters, none of which is a
slash. Glibc version 2.19 added stricter checks, that disallow slashes in names
of POSIX shared memory segments (which were previously allowed by glibc). Since
OpenSAF uses slashes in the names, the call to shm_open() now fails.

The solution replaces slashes with underscore characters in the shared memory
segment names.

diff --git a/osaf/libs/core/leap/os_defs.c b/osaf/libs/core/leap/os_defs.c
--- a/osaf/libs/core/leap/os_defs.c
+++ b/osaf/libs/core/leap/os_defs.c
@@ -773,7 +773,7 @@ uint32_t ncs_os_posix_shm(NCS_OS_POSIX_S
                        return NCSCC_RC_FAILURE;
                }
                shm_size = (long)req->info.open.i_size;
-               snprintf(shm_name, PATH_MAX, "/opensaf/%s", 
req->info.open.i_name);
+               snprintf(shm_name, PATH_MAX, "/opensaf_%s", 
req->info.open.i_name);
                req->info.open.o_fd = shm_open(shm_name, 
req->info.open.i_flags, 0666);
                if (req->info.open.o_fd < 0) {
                        return NCSCC_RC_FAILURE;
@@ -820,7 +820,7 @@ uint32_t ncs_os_posix_shm(NCS_OS_POSIX_S
 
        case NCS_OS_POSIX_SHM_REQ_UNLINK:       /* unlink is shm_unlink */
 
-               snprintf(shm_name, PATH_MAX, "/opensaf/%s", 
req->info.unlink.i_name);
+               snprintf(shm_name, PATH_MAX, "/opensaf_%s", 
req->info.unlink.i_name);
                ret_flag = shm_unlink(shm_name);
                if (ret_flag < 0) {
                        printf("shm_unlink failed with errno value %d\n", 
errno);
diff --git a/osaf/services/infrastructure/nid/scripts/opensafd.in 
b/osaf/services/infrastructure/nid/scripts/opensafd.in
--- a/osaf/services/infrastructure/nid/scripts/opensafd.in
+++ b/osaf/services/infrastructure/nid/scripts/opensafd.in
@@ -26,7 +26,6 @@ else
        . $pkgsysconfdir/nid.conf
 fi     
 
-shmdir=/dev/shm/opensaf
 binary=$pkglibdir/$prog
 lockfile=$lockdir/$prog
 amfnd_bin=$pkglibdir/osafamfnd
@@ -77,9 +76,9 @@ check_env() {
                exit 6
        fi
 
-       # /dev/shm, /var/lock & /var/run could be tmpfs mounts and needs to be 
+       # /var/lock & /var/run could be tmpfs mounts and needs to be
        # recreated at each boot
-       directories="$shmdir $lockdir $pkgpiddir"
+       directories="$lockdir $pkgpiddir"
        for directory in $directories; do
                mkdir -p $directory
                if [ -n "$OPENSAF_GROUP" ]; then
@@ -95,9 +94,7 @@ check_env() {
 
 clean_shm() {
        # Remove shared memory files created by OpenSAF
-       if [ -d /dev/shm/opensaf ]; then
-               rm -rf /dev/shm/opensaf
-       fi
+       find /dev/shm/. -maxdepth 1 -name 'opensaf_*' -exec rm -f {} \;
 }
 
 enable_coredump() {

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to