コード例 #1
0
ファイル: hj_hdl.c プロジェクト: helioloureiro/opensaf-fork
bool ncslpg_destroy(NCSLPG_OBJ *pg)
{
	if (pg->open == false)
		return false;	/* already closed            */
	pg->open = false;	/* stop others from entering */
	while (pg->inhere != 0)	/* Anybody inhere??          */
		m_NCS_TASK_SLEEP(1);	/* OK, I'll wait; could do semaphore I suppose */

	return true;		/* Invoker can proceed to get rid of protected thing */
}
コード例 #2
0
int main(int argc, char *argv[])
{
	daemonize(argc, argv);

	if (__init_eds() != NCSCC_RC_SUCCESS) {
		LOG_ER("EDS Initialization failed");
		exit(EXIT_FAILURE);
	}

	while (1) {
		m_NCS_TASK_SLEEP(0xfffffff0);
	}

	exit(1);
}
コード例 #3
0
int main(int argc, char *argv[])
{
	daemonize(argc, argv);

	if (__init_cpd() != NCSCC_RC_SUCCESS) {
		syslog(LOG_ERR, "__init_dts() failed");
		exit(EXIT_FAILURE);
	}

	while (1) {
		m_NCS_TASK_SLEEP(0xfffffff0);
	}

	exit(1);
}
コード例 #4
0
/****************************************************************************
  Name          : avnd_mon_process

  Description   : This routine is an entry point for the AvND PM task. 

  Arguments     : arg - ptr to the cb handle

  Return Values : None

  Notes         : None
******************************************************************************/
void avnd_mon_process(void *arg)
{
	unsigned int mon_rate;
	char *tmp_ptr;

	tmp_ptr = getenv("AVND_PM_MONITORING_RATE");
	if (tmp_ptr) 
		mon_rate = atoi(tmp_ptr);
	else
		mon_rate = AVND_PM_MONITORING_INTERVAL;

	while (1) {
		avnd_mon_pids(avnd_cb);
		m_NCS_TASK_SLEEP(mon_rate);
	}
}
コード例 #5
0
int main(int argc, char *argv[])
{
	daemonize(argc, argv);

	if (__init_dts() != NCSCC_RC_SUCCESS) {
		syslog(LOG_ERR, "__init_dts() failed");
		exit(EXIT_FAILURE);
	}

	if (nid_notify("DTSV", NCSCC_RC_SUCCESS, NULL) != NCSCC_RC_SUCCESS) {
		LOG_ER("nid_notify failed");
		exit(EXIT_FAILURE);
	}

	while (1) {
		m_NCS_TASK_SLEEP(0xfffffff0);
	}

	exit(1);
}
コード例 #6
0
/****************************************************************************
  Name          : pxy_pxd_amf_process
 
  Description   : This routine is an entry point for the AMF interface task.
                  It demonstrates the use of following AMF APIs
                  a) saAmfInitialize
                  b) saAmfSelectionObjectGet
                  c) saAmfCompNameGet
                  d) saAmfComponentRegister
                  e) saAmfDispatch
 
  Arguments     : None.
 
  Return Values : None.
 
  Notes         : None
******************************************************************************/
void pxy_pxd_amf_process (void)
{
   SaAisErrorT        rc;
   NCS_SEL_OBJ_SET    wait_sel_objs, all_sel_objs;
   SaSelectionObjectT pxy_amf_sel_obj,pxd_amf_sel_obj[PXY_PXD_NUM_OF_PROXIED_COMP];
   NCS_SEL_OBJ        pxy_amf_ncs_sel_obj,pxd_amf_ncs_sel_obj[PXY_PXD_NUM_OF_PROXIED_COMP];
   NCS_SEL_OBJ        highest_sel_obj,wait_sel_fd;
   int ret = 0;
   uns32 comp_inv_hc_time_out = 500;
   uns32 index = 0;

   /* this is to allow to establish MDS session with AvSv */
   m_NCS_TASK_SLEEP(3000);

   pxy_pxd_proxy_initialize();   

   rc = pxy_pxd_proxy_amf_init();

   if (SA_AIS_OK != rc)
      return;
   for(index = 0; index < PXY_PXD_NUM_OF_PROXIED_COMP; index++)
     rc = pxy_pxd_proxied_amf_init(index);

   if (SA_AIS_OK != rc)
      return;

   /* Get the selection object corresponding to this AMF handle */
   rc = saAmfSelectionObjectGet(pxy_pxd_cb.pxy_info.amfHandle, &pxy_amf_sel_obj);
   if (SA_AIS_OK != rc)
   {
      saAmfFinalize(pxy_pxd_cb.pxy_info.amfHandle);
      return;
   }
   
   for(index = 0; index < PXY_PXD_NUM_OF_PROXIED_COMP; index++)
   {
     /* Get the selection object corresponding to this AMF handle */
     rc = saAmfSelectionObjectGet(pxy_pxd_cb.pxd_info[index].amfHandle, 
                                  &pxd_amf_sel_obj[index]);
     if (SA_AIS_OK != rc)
     {
       saAmfFinalize(pxy_pxd_cb.pxy_info.amfHandle);
       printf("\n AMF Selection Object Get Failed for index %d !!!\n",index);
       return;
     }
   }

   printf("\n AMF Selection Object Get Successful !!! \n");

   rc = saAmfComponentNameGet(pxy_pxd_cb.pxy_info.amfHandle, 
                                 &pxy_pxd_cb.pxy_info.compName);
   if (SA_AIS_OK != rc)
   {
      saAmfFinalize(pxy_pxd_cb.pxy_info.amfHandle);
      return;
   }

   printf("\n Component Name Get Successful !!! \n CompName: %s \n",
                      pxy_pxd_cb.pxy_info.compName.value);


   rc = saAmfComponentRegister(pxy_pxd_cb.pxy_info.amfHandle, 
                               &pxy_pxd_cb.pxy_info.compName, 0);
   if (SA_AIS_OK != rc)
   {
      saAmfFinalize(pxy_pxd_cb.pxy_info.amfHandle);
      return;
   }

   printf("\n Proxy Component Registered !!! \n");

   /* Reset the wait select objects */
   m_NCS_SEL_OBJ_ZERO(&all_sel_objs);

   m_SET_FD_IN_SEL_OBJ((uns32)pxy_amf_sel_obj, pxy_amf_ncs_sel_obj);
   m_NCS_SEL_OBJ_SET(pxy_amf_ncs_sel_obj, &all_sel_objs);
   highest_sel_obj = pxy_amf_ncs_sel_obj;

   for(index = 0; index < PXY_PXD_NUM_OF_PROXIED_COMP; index++)
   {
    m_SET_FD_IN_SEL_OBJ((uns32)pxd_amf_sel_obj[index], pxd_amf_ncs_sel_obj[index]);
    m_NCS_SEL_OBJ_SET(pxd_amf_ncs_sel_obj[index], &all_sel_objs);
    highest_sel_obj = m_GET_HIGHER_SEL_OBJ(highest_sel_obj, pxd_amf_ncs_sel_obj[index]);
   }

   wait_sel_objs = all_sel_objs;
   wait_sel_fd  = highest_sel_obj;

   /* Now wait forever */
   while ((ret = m_NCS_SEL_OBJ_SELECT(wait_sel_fd, &wait_sel_objs, NULL, NULL,
           &comp_inv_hc_time_out)) != -1)
   {
    comp_inv_hc_time_out = 500;
    /* Check if it's an event from AMF */
    if(m_NCS_SEL_OBJ_ISSET(pxy_amf_ncs_sel_obj, &wait_sel_objs))
    {
      printf("\n Got Proxy AMF event!!! \n");
      /* There is an AMF callback waiting to be be processed. Process it */
      rc = saAmfDispatch(pxy_pxd_cb.pxy_info.amfHandle, SA_DISPATCH_ALL);
      if (SA_AIS_OK != rc)
      {
         printf("\n Proxy saAmfDispatch failed !!! \n");
         break;
      }
    }
   for(index = 0; index < PXY_PXD_NUM_OF_PROXIED_COMP; index++)
   {
    if(TRUE == pxy_pxd_cb.pxd_info[index].reg_pxied_comp)
    {
      printf("\n Before registering pxd[%d]!!!\n",index);
      /* Need to register proxied component */
      rc = saAmfComponentRegister(pxy_pxd_cb.pxd_info[index].amfHandle,
                                   &pxy_pxd_cb.pxd_info[index].compName,
                                   &pxy_pxd_cb.pxy_info.compName);
      if (SA_AIS_OK == rc)
      {
        printf("\n Proxied[%d] Component Registeration Successful. "
                              "Comp %s. rc is %d\n",index,
                              pxy_pxd_cb.pxd_info[index].compName.value,rc);
        pxy_pxd_cb.pxd_info[index].health_start = TRUE;
        pxy_pxd_cb.pxd_info[index].reg_pxied_comp = FALSE;
      }
      else if (SA_AIS_ERR_TRY_AGAIN == rc)
      {
        printf("\n Proxied[%d] Component Registeration failed. TRY_AGAIN"
                              " Comp %s. rc is %d\n",index,
                              pxy_pxd_cb.pxd_info[index].compName.value,rc);
      }
      else
      {
        printf("\n Proxied[%d] Component Registeration failed."
                              " Comp %s. rc is %d\n",index,
                              pxy_pxd_cb.pxd_info[index].compName.value,rc);
        pxy_pxd_cb.pxd_info[index].reg_pxied_comp = FALSE;
      }
     }
    } /* if(TRUE == pxy_pxd_cb.reg_pxied_comp) */

   /* Section 1 Starts : Health Check : SA_AMF_HEALTHCHECK_AMF_INVOKED */
   {
    SaAmfHealthcheckInvocationT    hc_inv;
    SaAmfRecommendedRecoveryT      rec_rcvr;

     for(index = 0; index < PXY_PXD_NUM_OF_PROXIED_COMP; index++)
     {
       if(TRUE == pxy_pxd_cb.pxd_info[index].health_start)
       { 
        printf("\n Before registering hc [%d]!!!\n",index);
        hc_inv = SA_AMF_HEALTHCHECK_AMF_INVOKED;
        rec_rcvr = SA_AMF_COMPONENT_FAILOVER;

        rc = saAmfHealthcheckStart(pxy_pxd_cb.pxd_info[index].amfHandle, 
                                   &pxy_pxd_cb.pxd_info[index].compName, 
                                   &pxy_pxd_cb.pxd_info[index].healthcheck_key,
                                   hc_inv, rec_rcvr);
        if (SA_AIS_OK == rc )
        {
          printf("Started AMF-Initiated HealthCheck (with Component "
                          "Failover Recommended Recovery) \n Comp: %s \n" 
                          "HealthCheckKey: %s \n",
                          pxy_pxd_cb.pxd_info[index].compName.value, 
                          pxy_pxd_cb.pxd_info[index].healthcheck_key.key);
          pxy_pxd_cb.pxd_info[index].health_start = FALSE;   
          pxy_pxd_cb.pxd_info[index].health_start_comp_inv = TRUE;   
        }
        else if(SA_AIS_ERR_TRY_AGAIN == rc)
        {
          printf(" AMF-Initiated HealthCheck TRY_AGAIN (with Component"
                            " Failover Recommended Recovery) \n Comp: %s \n" 
                            "HealthCheckKey: %s. Res %d \n",
                            pxy_pxd_cb.pxd_info[index].compName.value, 
                            pxy_pxd_cb.pxd_info[index].healthcheck_key.key, rc);
        }
        else
        {
          printf(" AMF-Initiated HealthCheck failed (with Component "
                            "Failover Recommended Recovery) \n Comp: %s \n" 
                            "HealthCheckKey: %s. Res %d \n",
                            pxy_pxd_cb.pxd_info[index].compName.value, 
                            pxy_pxd_cb.pxd_info[index].healthcheck_key.key, rc);
          pxy_pxd_cb.pxd_info[index].health_start = FALSE;   
        }
       } /* if(TRUE == pxy_pxd_cb.pxd_info[index].health_start)*/ 
     }
   }
   /* Section 1 Ends : Health Check : SA_AMF_HEALTHCHECK_AMF_INVOKED */

  if(TRUE == pxy_pxd_cb.unreg_pxied_comp)
  {
   for(index = 0; index < PXY_PXD_NUM_OF_PROXIED_COMP; index++)
   {
      printf("\n Before unregistering PXD[%d]!!! \n",index);
      /* Need to unregister proxied component */
       rc = saAmfComponentUnregister(pxy_pxd_cb.pxd_info[index].amfHandle,
                                     &pxy_pxd_cb.pxd_info[index].compName,
                                     &pxy_pxd_cb.pxy_info.compName);
       if (SA_AIS_OK != rc)
       {
          printf("\n Proxied Component unreg failed. Comp %s, Pxy Comp %s, Res %d\n",
                                pxy_pxd_cb.pxd_info[index].compName.value,
                                pxy_pxd_cb.pxy_info.compName.value,rc);
       }
       else
          printf("\n Proxied Component unreg Succ. Comp %s, Pxy Comp %s\n",
                                pxy_pxd_cb.pxd_info[index].compName.value,
                                pxy_pxd_cb.pxy_info.compName.value);
       pxy_pxd_cb.unreg_pxied_comp = FALSE;
       pxy_pxd_cb.pxd_info[index].health_start_comp_inv = FALSE;
   }
  }

   for(index = 0; index < PXY_PXD_NUM_OF_PROXIED_COMP; index++)
   {
    /* Check if it's an event from AMF */
    if(m_NCS_SEL_OBJ_ISSET(pxd_amf_ncs_sel_obj[index], &wait_sel_objs))
    {
      printf("\n Before Pxd dispatch PXD[%d] !!!\n",index);
      /* There is an AMF callback waiting to be be processed. Process it */
      rc = saAmfDispatch(pxy_pxd_cb.pxd_info[index].amfHandle, SA_DISPATCH_ONE);
      if (SA_AIS_OK != rc)
      {
         printf("\n PXD[%d] saAmfDispatch failed !!! \n",index);
         break;
      }
    }
   }
      /* Again set AMF select object to wait for another callback */
      wait_sel_objs = all_sel_objs;
      wait_sel_fd  = highest_sel_obj;
   }/* While loop */

   printf("\n\n Proxy Exited, ret %d!!!\n\n",ret);

   return;
}
コード例 #7
0
/*****************************************************************************

  PROCEDURE NAME:       rda_callback_task

  DESCRIPTION:          Task main routine to perform callback mechanism


  ARGUMENTS:

  RETURNS:

    PCSRDA_RC_SUCCESS:

  NOTES:

*****************************************************************************/
static uns32 rda_callback_task(RDA_CALLBACK_CB *rda_callback_cb)
{
    char msg[64] = { 0 };
    uns32 rc = PCSRDA_RC_SUCCESS;
    int value = -1;
    int retry_count = 0;
    NCS_BOOL conn_lost = FALSE;
    RDE_RDA_CMD_TYPE cmd_type = 0;
    PCS_RDA_CB_INFO cb_info;

    while (!rda_callback_cb->task_terminate) {
        /*
         ** Escalate the issue if the connection with server is not
         ** established after certain retries.
         */
        if (retry_count >= 100) {
            (*rda_callback_cb->callback_ptr) (rda_callback_cb->callback_handle,
                                              &cb_info, PCSRDA_RC_FATAL_IPC_CONNECTION_LOST);

            break;
        }

        /*
         ** Retry if connection with server is lost
         */
        if (conn_lost == TRUE) {
            m_NCS_TASK_SLEEP(1000);
            retry_count++;

            /*
             ** Connect
             */
            rc = rda_connect(&rda_callback_cb->sockfd);
            if (rc != PCSRDA_RC_SUCCESS) {
                continue;
            }

            /*
             ** Send callback reg request messgae
             */
            rc = rda_callback_req(rda_callback_cb->sockfd);
            if (rc != PCSRDA_RC_SUCCESS) {
                rda_disconnect(rda_callback_cb->sockfd);
                continue;
            }

            /*
             ** Connection established
             */
            retry_count = 0;
            conn_lost = FALSE;
        }

        /*
         ** Recv async role response
         */
        rc = rda_read_msg(rda_callback_cb->sockfd, msg, sizeof(msg));
        if ((rc == PCSRDA_RC_TIMEOUT) || (rc == PCSRDA_RC_FATAL_IPC_CONNECTION_LOST)) {
            if (rc == PCSRDA_RC_FATAL_IPC_CONNECTION_LOST) {
                close(rda_callback_cb->sockfd);
                rda_callback_cb->sockfd = -1;
                conn_lost = TRUE;
            }
            continue;
        } else if (rc != PCSRDA_RC_SUCCESS) {
            /*
             ** Escalate the problem to the application
             */
            (*rda_callback_cb->callback_ptr) (rda_callback_cb->callback_handle, &cb_info, rc);
            continue;
        }

        rda_parse_msg(msg, &cmd_type, &value);
        if ((cmd_type != RDE_RDA_HA_ROLE) || (value < 0)) {
            /*TODO: What to do here - shankar */
            continue;
        }

        /*
         ** Invoke callback
         */
        cb_info.cb_type = PCS_RDA_ROLE_CHG_IND;
        cb_info.info.io_role = value;

        (*rda_callback_cb->callback_ptr) (rda_callback_cb->callback_handle, &cb_info, PCSRDA_RC_SUCCESS);
    }

    return rc;
}