Hi Hung,
The present code already has 3seconds delay.
Published patch, also sleeps for same 3 seconds.
If the veteran IMMD can not send the INTRO event for 3 seconds , then
there is some problem with the system.
waiting for 3 seconds is a long wait to send intro. the priority part
also may not be required.
Thanks,
Neel.
On Thursday 10 March 2016 12:56 PM, Hung Nguyen wrote:
> osaf/services/saf/immsv/immd/immd_cb.h | 3 ++
> osaf/services/saf/immsv/immd/immd_main.c | 36
> ++++++++++++++++++++++++++++---
> osaf/services/saf/immsv/immd/immd_mds.c | 20 ++++++++++++++++-
> 3 files changed, 53 insertions(+), 6 deletions(-)
>
>
> IMMD will wait for intro message from veterans and give up after 3 seconds if
> can't find any veteran.
>
> This patch also improves the startup time of IMMD.
> IMMD will not always 'sleep' for 3 seconds. It will just wait until a veteran
> attaches.
> Also the standby IMMD will not have any delay in startup process.
>
> diff --git a/osaf/services/saf/immsv/immd/immd_cb.h
> b/osaf/services/saf/immsv/immd/immd_cb.h
> --- a/osaf/services/saf/immsv/immd/immd_cb.h
> +++ b/osaf/services/saf/immsv/immd/immd_cb.h
> @@ -141,6 +141,9 @@ typedef struct immd_cb_tag {
> SaUint16T mScAbsenceAllowed; /* Non zero if SC absence is allowed (loss
> of both IMMDs/SCs).
> Value is number of seconds of SC absence
> tolerated. */
> MDS_DEST payload_coord_dest; /* IMMND coord may be at payload if
> mScAbsenceAllowed is nonzero */
> +
> + NCS_LOCK veteran_sync_lock; /* Sync up with veteran payload after
> headless */
> + NCS_SEL_OBJ veteran_sync_sel; /* Sync up with veteran payload after
> headless */
> } IMMD_CB;
>
> uint32_t immd_immnd_info_tree_init(IMMD_CB *cb);
> 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
> @@ -33,6 +33,7 @@
> #include <rda_papi.h>
> #include <daemon.h>
> #include <nid_api.h>
> +#include "osaf_poll.h"
>
> #include "immd.h"
> #include <immd_proc.h>
> @@ -257,10 +258,16 @@ int main(int argc, char *argv[])
> }
>
> if(scAbsenceAllowed) {
> - LOG_NO("******* SC_ABSENCE_ALLOWED (Headless Hydra) is
> configured: %u ***********",
> - scAbsenceAllowed);
> - LOG_NO("Waiting 3 seconds to allow IMMND MDS attachments to get
> processed.");
> - sleep(3);
> + /* 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;
> @@ -270,6 +277,27 @@ int main(int argc, char *argv[])
> goto done;
> }
>
> + 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 {
> + TRACE("osaf_poll_one_fd on veteran_sync_sel
> succeeded");
> + }
> + }
> +
> + 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);
>
> /* Get file descriptor for mailbox */
> diff --git a/osaf/services/saf/immsv/immd/immd_mds.c
> b/osaf/services/saf/immsv/immd/immd_mds.c
> --- a/osaf/services/saf/immsv/immd/immd_mds.c
> +++ b/osaf/services/saf/immsv/immd/immd_mds.c
> @@ -489,6 +489,7 @@ static uint32_t immd_mds_rcv(IMMD_CB *cb
> {
> uint32_t rc = NCSCC_RC_SUCCESS;
> IMMSV_EVT *pEvt = (IMMSV_EVT *)rcv_info->i_msg;
> + NCS_IPC_PRIORITY prio = NCS_IPC_PRIORITY_NORMAL;
>
> pEvt->sinfo.ctxt = rcv_info->i_msg_ctxt;
> pEvt->sinfo.dest = rcv_info->i_fr_dest;
> @@ -497,8 +498,23 @@ static uint32_t immd_mds_rcv(IMMD_CB *cb
> pEvt->sinfo.stype = MDS_SENDTYPE_RSP;
> }
>
> + /* Set priority of intro messages from veteran payloads to
> PRIORITY_HIGH.
> + * IMMD will process them before the intro messages from other IMMNDs.
> */
> + if (cb->mScAbsenceAllowed &&
> + pEvt->info.immd.type == IMMD_EVT_ND2D_INTRO &&
> + pEvt->info.immd.info.ctrl_msg.refresh == 2) {
> +
> + prio = NCS_IPC_PRIORITY_HIGH;
> +
> + m_NCS_LOCK(&immd_cb->veteran_sync_lock,NCS_LOCK_WRITE);
> + if (cb->veteran_sync_sel.raise_obj != -1) { /* Check if the
> sel_obj is not destroyed */
> + m_NCS_SEL_OBJ_IND(&cb->veteran_sync_sel);
> + }
> + m_NCS_UNLOCK(&immd_cb->veteran_sync_lock,NCS_LOCK_WRITE);
> + }
> +
> /* Put it in IMMD's Event Queue */
> - rc = m_NCS_IPC_SEND(&cb->mbx, (NCSCONTEXT)pEvt,
> NCS_IPC_PRIORITY_NORMAL);
> + rc = m_NCS_IPC_SEND(&cb->mbx, (NCSCONTEXT)pEvt, prio);
> if (NCSCC_RC_SUCCESS != rc) {
> LOG_WA("IMMD - IPC SEND FAILED");
> }
> @@ -542,7 +558,7 @@ static uint32_t immd_mds_svc_evt(IMMD_CB
> evt->info.immd.info.mds_info.node_id = svc_evt->i_node_id;
>
> /* Put it in IMMD's Event Queue */
> - rc = m_NCS_IPC_SEND(&cb->mbx, (NCSCONTEXT)evt, NCS_IPC_PRIORITY_HIGH);
> + rc = m_NCS_IPC_SEND(&cb->mbx, (NCSCONTEXT)evt,
> NCS_IPC_PRIORITY_VERY_HIGH);
> if (NCSCC_RC_SUCCESS != rc) {
> LOG_WA("IMMD - IPC SEND FAILED");
> free(evt);
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel