osaf/services/saf/immsv/immd/immd_main.c |  60 ++++++++++++++++---------------
 1 files changed, 31 insertions(+), 29 deletions(-)


Basically, the delay should take place after initializing MDS.
This patch moves the code to initialize_for_assignment().
That way we can make sure that the delay is only started after MDS 
initialization,
also we don't have to depend on the output of rda_get_role().

diff --git a/osaf/services/saf/immsv/immd/immd_main.c 
b/osaf/services/saf/immsv/immd/immd_main.c
--- a/osaf/services/saf/immsv/immd/immd_main.c
+++ b/osaf/services/saf/immsv/immd/immd_main.c
@@ -200,6 +200,20 @@ uint32_t initialize_for_assignment(IMMD_
        uint32_t rc = NCSCC_RC_SUCCESS;
        if (cb->fully_initialized || ha_state == SA_AMF_HA_QUIESCED) goto done;
        cb->ha_state = ha_state;
+
+       if(cb->mScAbsenceAllowed && cb->ha_state == SA_AMF_HA_ACTIVE) {
+               /* Create the sel-obj before initializing MDS.
+                * This way, we can avoid an extra 'veteran_sync_awaited' 
variable in IMMD_CB */
+               if ((rc = m_NCS_LOCK_INIT(&immd_cb->veteran_sync_lock)) != 
NCSCC_RC_SUCCESS) {
+                       LOG_ER("Failed to get veteran_sync_lock lock");
+                       goto done;
+               }
+               if ((rc = m_NCS_SEL_OBJ_CREATE(&immd_cb->veteran_sync_sel)) != 
NCSCC_RC_SUCCESS) {
+                       LOG_ER("Failed to create veteran_sync_sel sel_obj");
+                       goto done;
+               }
+       }
+
        if ((rc = immd_mds_register(cb, ha_state)) != NCSCC_RC_SUCCESS) {
                LOG_ER("immd_mds_register FAILED %d", rc);
                goto done;
@@ -217,6 +231,23 @@ uint32_t initialize_for_assignment(IMMD_
                goto done;
        }
        cb->fully_initialized = true;
+
+       if (cb->mScAbsenceAllowed && cb->ha_state == SA_AMF_HA_ACTIVE) {
+               /* If this IMMD has active role, wait for veteran payloads.
+                * Give up after 3 seconds if there's no veteran payloads. */
+               LOG_NO("Waiting 3 seconds to allow IMMND MDS attachments to get 
processed.");
+
+               if 
(osaf_poll_one_fd(m_GET_FD_FROM_SEL_OBJ(immd_cb->veteran_sync_sel), 3000) != 1) 
{
+                       TRACE("osaf_poll_one_fd on veteran_sync_sel failed or 
timed out");
+               } else {
+                       LOG_NO("Received intro message from veteran payload, 
stop waiting");
+               }
+
+               m_NCS_LOCK(&immd_cb->veteran_sync_lock, NCS_LOCK_WRITE);
+               m_NCS_SEL_OBJ_DESTROY(&immd_cb->veteran_sync_sel);
+               m_NCS_UNLOCK(&immd_cb->veteran_sync_lock, NCS_LOCK_WRITE);
+       }
+
 done:
        TRACE_LEAVE2("rc = %u", rc);
        return rc;
@@ -275,19 +306,6 @@ int main(int argc, char *argv[])
                }
        }
 
-       if(scAbsenceAllowed) {
-               /* Create the sel-obj before initializing MDS.
-                * This way, we can avoid an extra 'veteran_sync_awaited' 
variable in IMMD_CB */
-               if (m_NCS_LOCK_INIT(&immd_cb->veteran_sync_lock) != 
NCSCC_RC_SUCCESS) {
-                       LOG_ER("Failed to get veteran_sync_lock lock");
-                       goto done;
-               }
-               if (m_NCS_SEL_OBJ_CREATE(&immd_cb->veteran_sync_sel)!= 
NCSCC_RC_SUCCESS) {
-                       LOG_ER("Failed to create veteran_sync_sel sel_obj");
-                       goto done;
-               }
-       }
-
        immd_cb->mScAbsenceAllowed = scAbsenceAllowed;
 
        if (immd_initialize() != NCSCC_RC_SUCCESS) {
@@ -298,22 +316,6 @@ int main(int argc, char *argv[])
        if(scAbsenceAllowed) {
                LOG_NO("******* SC_ABSENCE_ALLOWED (Headless Hydra) is 
configured: %u ***********",
                        scAbsenceAllowed);
-
-               /* If this IMMD has active role, wait for veteran payloads.
-                * Give up after 3 seconds if there's no veteran payload. */
-               if (immd_cb->ha_state == SA_AMF_HA_ACTIVE) {
-                       LOG_NO("Waiting 3 seconds to allow IMMND MDS 
attachments to get processed.");
-
-                       if 
(osaf_poll_one_fd(m_GET_FD_FROM_SEL_OBJ(immd_cb->veteran_sync_sel), 3000) != 1) 
{
-                               TRACE("osaf_poll_one_fd on veteran_sync_sel 
failed or timed out");
-                       } else {
-                               LOG_NO("Received intro message from veteran 
payload, stop waiting");
-                       }
-               }
-
-               m_NCS_LOCK(&immd_cb->veteran_sync_lock,NCS_LOCK_WRITE);
-               m_NCS_SEL_OBJ_DESTROY(&immd_cb->veteran_sync_sel);
-               m_NCS_UNLOCK(&immd_cb->veteran_sync_lock,NCS_LOCK_WRITE);
        }
 
        daemon_sigterm_install(&term_fd);

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to