Ejemplo n.º 1
0
/****************************************************************************
 * PROCEDURE: mbcsv_lib_init
 *
 * Description   : This is the function which initalize the mbcsv libarary.
 *                 This function creates an global lock, creates MBCSV linked 
 *                 list, etc.
 *
 * Arguments     : req_info - Request info.
 *
 * Return Values : SA_AIS_OK/Failure code.
 *
 * Notes         : None.
 *****************************************************************************/
uint32_t mbcsv_lib_init(NCS_LIB_REQ_INFO *req_info)
{
	NCS_PATRICIA_PARAMS pt_params;
	uint32_t rc = SA_AIS_OK;
	TRACE_ENTER();

	if (mbcsv_cb.created == true) {
		TRACE_LEAVE2("Lib init request failed: MBCA already created");
		return SA_AIS_ERR_INIT;
	}

	/*
	 * Create global lock 
	 */
	m_NCS_LOCK_INIT(&mbcsv_cb.global_lock);

	/* 
	 * Create patricia tree for the MBCA registration instance 
	 */
	pt_params.key_size = sizeof(uint32_t);

	if (ncs_patricia_tree_init(&mbcsv_cb.reg_list, &pt_params) != NCSCC_RC_SUCCESS) {
		TRACE_4("pat tree init failed");
		rc = SA_AIS_ERR_FAILED_OPERATION;
		goto err1;
	}

	if (NCSCC_RC_SUCCESS != mbcsv_initialize_mbx_list()) {
		TRACE_4("pat tree init for mailbox failed");
		rc = SA_AIS_ERR_FAILED_OPERATION;
		goto err2;
	}

	/* 
	 * Create patricia tree for the peer list 
	 */
	if (mbcsv_initialize_peer_list() != NCSCC_RC_SUCCESS) {
		TRACE_4("pat tree init for peer list failed");
		rc = SA_AIS_ERR_FAILED_OPERATION;
		goto err3;
	}

	mbcsv_cb.created = true;

	return rc;

	/* Handle Different Error Situations */
 err3:
	ncs_patricia_tree_destroy(&mbcsv_cb.mbx_list);
	m_NCS_LOCK_DESTROY(&mbcsv_cb.mbx_list_lock);
 err2:
	ncs_patricia_tree_destroy(&mbcsv_cb.reg_list);
 err1:
	m_NCS_LOCK_DESTROY(&mbcsv_cb.global_lock);
	TRACE_LEAVE();
	return rc;
}
Ejemplo n.º 2
0
void ncshm_delete(void)
{
	uint32_t i, j;
	HM_UNIT *unit;

	gl_im_created--;
	if (gl_im_created > 0)
		return;

	/* Destroy all the locks now. */
	for (i = 0; i < HM_POOL_CNT; i++) {
		if (m_NCS_LOCK_DESTROY(&gl_hm.lock[i]) != NCSCC_RC_SUCCESS) {
			m_LEAP_DBG_SINK_VOID;
		}
	}

	for (i = 0; i < HM_UNIT_CNT; i++) {
		if ((unit = gl_hm.unit[i]) != NULL) {
			for (j = 0; j < HM_BANK_CNT; j++) {
				if (unit->cells[j] != NULL)
					free(unit->cells[j]);
			}
			free(unit);
		}
	}

	/* Memset the gl_hm data structure. */
	memset(&gl_hm, 0, sizeof(HM_CORE));

	/* ncshm_init(); */	/* put struct back in start state.. Why not?? */
}
Ejemplo n.º 3
0
/****************************************************************************
  Name          : eda_destroy

  Description   : This routine destroys the EDA control block.

  Arguments     : destroy_info - ptr to the destroy info

  Return Values : None

  Notes         : None
******************************************************************************/
void eda_destroy(NCS_LIB_DESTROY *destroy_info)
{
    EDA_CB *cb = 0;
    TRACE_ENTER();

    /* retrieve EDA CB */
    cb = (EDA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_EDA, gl_eda_hdl);
    if (!cb) {
        TRACE_LEAVE2("global take handle failed: %u", gl_eda_hdl);
        return;
    }
    /* delete the hdl db */
    eda_hdl_list_del(&cb->eda_init_rec_list);

    /* unregister with MDS */
    eda_mds_finalize(cb);

    /* destroy the lock */
    m_NCS_LOCK_DESTROY(&cb->cb_lock);

    /* return EDA CB */
    ncshm_give_hdl(gl_eda_hdl);

    /* remove the association with hdl-mngr */
    ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, cb->cb_hdl);

    /* free the control block */
    m_MMGR_FREE_EDA_CB(cb);

    /* reset the global cb handle */
    gl_eda_hdl = 0;

    TRACE_LEAVE();
    return;
}
Ejemplo n.º 4
0
/***********************************************************************//**
* @brief	This routine destroys the PLMA Control block.
*
* @param[in]	destroy_info - A pointer to the NCS_LIB_DESTROY structure.
*
* @return	NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
***************************************************************************/
uns32 plma_destroy(NCS_LIB_DESTROY *destroy_info)
{
	PLMA_CB *plma_cb = plma_ctrlblk;
	
	TRACE_ENTER();

	/* MDS unregister. */
	plma_mds_unregister();

	/** flush the EDU handle */
	m_NCS_EDU_HDL_FLUSH(&plma_cb->edu_hdl);	

	/** destroy the client tree */
	plma_client_tree_destroy();

	/** destroy the lock */
	m_NCS_LOCK_DESTROY(&plma_cb->cb_lock);

	/** make reference to plma_cb obsolete */ 
	plma_ctrlblk = NULL;


	TRACE_LEAVE();
	
	return NCSCC_RC_SUCCESS;
}
Ejemplo n.º 5
0
/****************************************************************************
 * Name          : eds_se_lib_destroy
 *
 * Description   : Invoked to destroy the EDS
 *                 
 *
 * Arguments     : 
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE..
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t eds_se_lib_destroy(NCS_LIB_REQ_INFO *req_info)
{
    /** Code to destroy the EDS **/
	EDS_CB *eds_cb;
	m_INIT_CRITICAL;
	TRACE_ENTER();

	if (NULL == (eds_cb = (NCSCONTEXT)ncshm_take_hdl(NCS_SERVICE_ID_EDS, gl_eds_hdl))) {
		LOG_ER("Handle take failed for global handle");
		TRACE_LEAVE();
		return (NCSCC_RC_FAILURE);
	} else {
		m_START_CRITICAL;
      /** Lock EDA_CB
       **/
		m_NCS_LOCK(&eds_cb->cb_lock, NCS_LOCK_WRITE);

		/* deregister from AMF */
		saAmfComponentUnregister(eds_cb->amf_hdl, &eds_cb->comp_name, NULL);

		/* End association from the AMF lib */
		saAmfFinalize(eds_cb->amf_hdl);

		/* Finalize with CLM */
		saClmFinalize(eds_cb->clm_hdl);

		/* Clean up all internal structures */
		eds_remove_reglist_entry(eds_cb, 0, true);

		/* Destroy the cb */
		eds_cb_destroy(eds_cb);

		/* Give back the handle */
		ncshm_give_hdl(gl_eds_hdl);
		ncshm_destroy_hdl(NCS_SERVICE_ID_GLD, gl_eds_hdl);

		/* Detach from IPC */
		m_NCS_IPC_DETACH(&eds_cb->mbx, eds_clear_mbx, eds_cb);

		/* Disconnect from MDS */
		eds_mds_finalize(eds_cb);

		/* Release the IPC */
		m_NCS_IPC_RELEASE(&eds_cb->mbx, NULL);

      /** UnLock EDA_CB
       **/
		m_NCS_UNLOCK(&eds_cb->cb_lock, NCS_LOCK_WRITE);
		m_NCS_LOCK_DESTROY(&eds_cb->cb_lock);
		m_MMGR_FREE_EDS_CB(eds_cb);

		gl_eds_hdl = 0;
		m_END_CRITICAL;
		TRACE("eds-cb-lib destroy done .");
	}

	TRACE_LEAVE();
	return (NCSCC_RC_SUCCESS);
}
Ejemplo n.º 6
0
/****************************************************************************
  Name          : ava_destroy
 
  Description   : This routine destroys the AvA control block.
 
  Arguments     : destroy_info - ptr to the destroy info
 
  Return Values : None
 
  Notes         : None
******************************************************************************/
void ava_destroy(NCS_LIB_DESTROY *destroy_info)
{
	AVA_CB *cb = 0;
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();

	/* retrieve AvA CB */
	cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl);
	if (!cb) {
		LOG_ER("Unable to take handle for control block");
		goto done;
	}

	/* delete the hdl db */
	ava_hdl_del(cb);
	TRACE_1("Deleted the handles DB");

	/* unregister with MDS */
	rc = ava_mds_unreg(cb);
	if (NCSCC_RC_SUCCESS != rc)
		TRACE_4("MDS unregistration failed");
	else
		TRACE_1("MDS unregistration success");

	/* EDU cleanup */
	m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl);
	TRACE_1("EDU cleanup failed");

	/* destroy the lock */
	m_NCS_LOCK_DESTROY(&cb->lock);
	TRACE_1("Destroying lock for control block failed");

	/* return AvA CB */
	ncshm_give_hdl(gl_ava_hdl);

	/* remove the association with hdl-mngr */
	ncshm_destroy_hdl(NCS_SERVICE_ID_AVA, cb->cb_hdl);
	TRACE_1("Removing association with handle manager failed");

	/* free the control block */
	free(cb);

	/* reset the global cb handle */
	gl_ava_hdl = 0;

 done:
	TRACE_LEAVE();
	return;
}
Ejemplo n.º 7
0
/****************************************************************************
  Name          : mqa_destroy
 
  Description   : This routine destroys the MQA control block.
 
  Arguments     : destroy_info - ptr to the destroy info
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
static uns32 mqa_destroy(NCS_LIB_DESTROY *destroy_info)
{
	MQA_CB *cb = 0;

	/* validate the CB */
	cb = (MQA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_MQA, gl_mqa_hdl);
	if (!cb)
		return NCSCC_RC_FAILURE;

	/* return MQA CB */
	ncshm_give_hdl(gl_mqa_hdl);

	/* remove the association with hdl-mngr */
	ncshm_destroy_hdl(NCS_SERVICE_ID_MQA, cb->agent_handle_id);

	if (m_NCS_LOCK(&cb->cb_lock, NCS_LOCK_WRITE) != NCSCC_RC_SUCCESS)	{
		TRACE("mqa_destroy Failed to acquire lock");
		return NCSCC_RC_FAILURE;
	}

	mqa_timer_table_destroy(cb);

	/* Unregister with ASAPi */
	mqa_asapi_unregister(cb);

	/* MDS unregister. */
	mqa_mds_unregister(cb);

	m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl);

	mqa_queue_tree_destroy(cb);

	/* delete all the client info */
	mqa_client_tree_destroy(cb);

	m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);

	/* destroy the lock */
	m_NCS_LOCK_DESTROY(&cb->cb_lock);

	/* de register with the flex log */
	mqa_flx_log_dereg();

	/* reset the global cb handle */
	gl_mqa_hdl = 0;

	return NCSCC_RC_SUCCESS;
}
Ejemplo n.º 8
0
/****************************************************************************
 * PROCEDURE     : mbcsv_lib_destroy
 *
 * Description   : This is the function which destroys the MBCSV.  
 *
 * Arguments     : None.
 *
 * Return Values : SA_AIS_OK/Failure code.
 *
 * Notes         : None.
 *****************************************************************************/
uint32_t mbcsv_lib_destroy(void)
{
	MBCSV_REG *mbc_reg;
	SS_SVC_ID svc_id = 0;
	SaAisErrorT rc = SA_AIS_OK;
	TRACE_ENTER();

	if (mbcsv_cb.created == false) {
		TRACE_LEAVE2("Lib destroy request failed: Create MBCA before destroying");
		return SA_AIS_ERR_EXIST;
	}

	m_NCS_LOCK(&mbcsv_cb.global_lock, NCS_LOCK_WRITE);

	mbcsv_cb.created = false;
	/* 
	 * Walk through MBCSv reg list and destroy all the registration instances.
	 */
	while (NULL != (mbc_reg = (MBCSV_REG *)ncs_patricia_tree_getnext(&mbcsv_cb.reg_list, (const uint8_t *)&svc_id))) {
		svc_id = mbc_reg->svc_id;

		if (NCSCC_RC_SUCCESS != mbcsv_rmv_reg_inst((MBCSV_REG *)&mbcsv_cb.reg_list, mbc_reg)) {
			/* Not required to return for failure, log the err message and go 
			   ahead with cleanup */
			TRACE_4("Failed to remove this service instance:%u", mbc_reg->svc_id);
		}
	}

	ncs_patricia_tree_destroy(&mbcsv_cb.reg_list);

	/*
	 * Call function which will destroy and free all the entries of the peer list.
	 */
	mbcsv_destroy_peer_list();

	/*
	 * Call function which will destroy mail box list.
	 */
	mbcsv_destroy_mbx_list();

	m_NCS_UNLOCK(&mbcsv_cb.global_lock, NCS_LOCK_WRITE);
	m_NCS_LOCK_DESTROY(&mbcsv_cb.global_lock);

	TRACE_LEAVE();
	return rc;
}
Ejemplo n.º 9
0
/**************************************************************************\
 * exec_mod_cb_destroy
 *
 * Description       : Destroys module control block.
 *              
 * Call Arguments    : None  
 *
 * Returns:

 * SUCCESS/FAILURE   : NCSCC_RC_SUCCESS / NCSCC_RC_FAILURE 
 *
 * Notes:
 *
\**************************************************************************/
uns32 exec_mod_cb_destroy(void)
{
	SYSF_PID_LIST *exec_pid = NULL;
	uns8 pid = 0;

	if (module_cb.init == TRUE) {
		module_cb.init = FALSE;
		m_NCS_SIGNAL(SIGCHLD, SIG_DFL);

		close(module_cb.write_fd);
		close(module_cb.read_fd);

		m_NCS_TASK_RELEASE(module_cb.em_task_handle);

		m_NCS_LOCK(&module_cb.tree_lock, NCS_LOCK_WRITE);

		while (NULL != (exec_pid = (SYSF_PID_LIST *)ncs_patricia_tree_getnext(&module_cb.pid_list,
										      (const uns8 *)&pid))) {

			ncs_patricia_tree_del(&module_cb.pid_list, (NCS_PATRICIA_NODE *)exec_pid);

			if (exec_pid->tmr_id != NULL)
				m_NCS_TMR_DESTROY(exec_pid->tmr_id);

			m_MMGR_FREE_PRO_EXC(exec_pid);
		}

		if (ncs_patricia_tree_destroy(&module_cb.pid_list) != NCSCC_RC_SUCCESS) {
			return m_LEAP_DBG_SINK(NCSCC_RC_FAILURE);
		}

		m_NCS_UNLOCK(&module_cb.tree_lock, NCS_LOCK_WRITE);
	}

	m_NCS_LOCK_DESTROY(&module_cb.tree_lock);

	return NCSCC_RC_SUCCESS;
}
Ejemplo n.º 10
0
/****************************************************************************
  Name          : cpa_destroy
 
  Description   : This routine destroys the CPA control block.
 
  Arguments     : destroy_info - ptr to the destroy info
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
static uint32_t cpa_destroy(NCS_LIB_DESTROY *destroy_info)
{
	CPA_CB *cb = NULL;

	/* validate the CB */
	m_CPA_RETRIEVE_CB(cb);
	if (!cb)
		return NCSCC_RC_FAILURE;

	/* MDS unregister. */
	cpa_mds_unregister(cb);

	m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl);

	/* Destroy the CPA database */
	cpa_db_destroy(cb);

	/* destroy the lock */
	m_NCS_LOCK_DESTROY(&cb->cb_lock);

	/* return CPA CB Handle */
	ncshm_give_hdl(cb->agent_handle_id);

	/* remove the association with hdl-mngr */
	ncshm_destroy_hdl(NCS_SERVICE_ID_CPA, cb->agent_handle_id);

	TRACE_2("cpa lib destroy success ");

	/*  Memory leaks found in cpa_init.c */
	m_MMGR_FREE_CPA_CB(cb);

	/* reset the global cb handle */
	gl_cpa_hdl = 0;

	return NCSCC_RC_SUCCESS;
}
Ejemplo n.º 11
0
/****************************************************************************
  Name          : eda_destroy
 
  Description   : This routine destroys the EDA control block.
 
  Arguments     : destroy_info - ptr to the destroy info
 
  Return Values : None
 
  Notes         : None
******************************************************************************/
void eda_destroy(NCS_LIB_DESTROY *destroy_info)
{
	EDA_CB *cb = 0;

	/* retrieve EDA CB */
	cb = (EDA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_EDA, gl_eda_hdl);
	if (!cb) {
		m_LOG_EDSV_A(EDA_CB_HDL_TAKE_FAILED, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__, 0);
		return;
	}
	/* delete the hdl db */
	eda_hdl_list_del(&cb->eda_init_rec_list);

	/* unregister with MDS */
	eda_mds_finalize(cb);

	/* destroy the lock */
	m_NCS_LOCK_DESTROY(&cb->cb_lock);

	/* de register with the flex log */
	eda_flx_log_dereg();

	/* return EDA CB */
	ncshm_give_hdl(gl_eda_hdl);

	/* remove the association with hdl-mngr */
	ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, cb->cb_hdl);

	/* free the control block */
	m_MMGR_FREE_EDA_CB(cb);

	/* reset the global cb handle */
	gl_eda_hdl = 0;

	return;
}
Ejemplo n.º 12
0
/***********************************************************************//**
* @brief	This routine creates and initializes the PLMA Control block.
*
* @param[in]	create_info - A pointer to the structure that has creation 
*			      parameters, if any, are provided to libraries 
*			      in a command-line arguments style.
*
* @return	NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
***************************************************************************/
uns32 plma_create(NCS_LIB_CREATE *create_info)
{
	
	PLMA_CB *plma_cb;
	uns32    rc = NCSCC_RC_SUCCESS;
	if(!plma_ctrlblk){
		plma_ctrlblk = &_plma_cb;
	}

	plma_cb = plma_ctrlblk;
	
	TRACE_ENTER();
	/** validate create info */
	if (create_info == NULL){
		LOG_ER("PLMA : INVALID create_info RECEIVED");
		rc =  NCSCC_RC_FAILURE;
		goto end;
	}
	
	
	memset(plma_cb, 0, sizeof(PLMA_CB));


	/** Initialize the PLMA_CB lock */
	if (m_NCS_LOCK_INIT(&plma_cb->cb_lock) != NCSCC_RC_SUCCESS) {
		LOG_ER("PLMA: cb_lock INIT FAILED");
		rc = NCSCC_RC_FAILURE;
		goto lock_fail;
	}
	
	/** initialize the client tree */
	if (plma_client_tree_init() != NCSCC_RC_SUCCESS) {
		LOG_ER("PLMA: CLIENT TREE INIT FAILED");
		rc = NCSCC_RC_FAILURE;
		goto cl_tree_init_fail;
	}
	
	/** initialize the group tree */
	if (plma_group_tree_init() != NCSCC_RC_SUCCESS) {
		LOG_ER("PLMA: GROUP INFO TREE INIT FAILED");
		rc = NCSCC_RC_FAILURE;
		goto gr_tree_init_fail;
	}
	
	/** register with MDS */
	if (plma_mds_register() != NCSCC_RC_SUCCESS) {
		LOG_ER("PLMA: MDS REGISTER FAILED");
		rc = NCSCC_RC_FAILURE;
		goto mds_reg_fail;
	}

	/** EDU initialisation */
	if (m_NCS_EDU_HDL_INIT(&plma_cb->edu_hdl) != NCSCC_RC_SUCCESS) {
		LOG_ER("PLMA: EDU HDL INIT FAILED");
		rc = NCSCC_RC_FAILURE;
		goto edu_init_fail;
	}

	
	plma_sync_with_plms();
	
	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
	

edu_init_fail:
	plma_mds_unregister();
mds_reg_fail:
	plma_group_tree_destroy();
gr_tree_init_fail:
	plma_client_tree_destroy();
cl_tree_init_fail:
	/** destroy the lock */
	m_NCS_LOCK_DESTROY(&plma_cb->cb_lock);
lock_fail:
	/** make reference to plma_cb obsolete */ 
	plma_ctrlblk = NULL;
end:
	TRACE_LEAVE();
	return rc;
	

}
Ejemplo n.º 13
0
/****************************************************************************
  Name          : cpa_create
 
  Description   : This routine creates & initializes the CPA control block.
 
  Arguments     : create_info - ptr to the create info
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
static uint32_t cpa_create(NCS_LIB_CREATE *create_info)
{
	CPA_CB *cb = NULL;
	uint32_t rc;

	/* validate create info */
	if (create_info == NULL)
		return NCSCC_RC_FAILURE;


	/* Malloc the CB for CPA */
	cb = m_MMGR_ALLOC_CPA_CB;
	if (cb == NULL) {
		TRACE_4("cpa mem alloc failed for CPA_CB");
		goto cb_alloc_fail;
	}
	memset(cb, 0, sizeof(CPA_CB));

	/* assign the CPA pool-id (used by hdl-mngr) */
	cb->pool_id = NCS_HM_POOL_ID_COMMON;

	/* create the association with hdl-mngr */
	if (!(cb->agent_handle_id = ncshm_create_hdl(cb->pool_id, NCS_SERVICE_ID_CPA, (NCSCONTEXT)cb))) {
		TRACE_4("cpa create failed int ncsshm_create_hdl");
		goto hm_create_fail;
	}
	/*store the hdl in the global variable */
	gl_cpa_hdl = cb->agent_handle_id;

	/* get the process id */
	cb->process_id = getpid();

	/* initialize the cpa cb lock */
	if (m_NCS_LOCK_INIT(&cb->cb_lock) != NCSCC_RC_SUCCESS) {
		TRACE_4("cpa create failed in LOCK_INIT ");
		goto lock_init_fail;
	}

	/* Initalize the CPA Trees & Linked lists */
	rc = cpa_db_init(cb);
	if (rc != NCSCC_RC_SUCCESS) {
		/* No need to log here, already logged in cpa_db_init */
		goto db_init_fail;
	}

	/* register with MDS */
	if (cpa_mds_register(cb) != NCSCC_RC_SUCCESS) {
		/* No need to log here, already logged in cpa_mds_register  */
		goto mds_reg_fail;
	}

	cpa_sync_with_cpnd(cb);

	/* EDU initialisation */
	if (m_NCS_EDU_HDL_INIT(&cb->edu_hdl) != NCSCC_RC_SUCCESS) {
		TRACE_4("cpa create failed in EDU_INIT:");
		goto edu_init_fail;
	}

	TRACE_1("cpa create sucess,Lib init success");
	return NCSCC_RC_SUCCESS;

/* error8:
   m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl); */

 edu_init_fail:
	/* MDS unregister. */
	cpa_mds_unregister(cb);

 mds_reg_fail:
	cb->is_cpnd_joined_clm = false;
	cpa_db_destroy(cb);

 db_init_fail:
	/* destroy the lock */
	cb->is_cpnd_joined_clm = false;
	m_NCS_LOCK_DESTROY(&cb->cb_lock);

 lock_init_fail:
	/* remove the association with hdl-mngr */
	ncshm_destroy_hdl(NCS_SERVICE_ID_CPA, cb->agent_handle_id);
	gl_cpa_hdl = 0;

 hm_create_fail:
	/* Free the CB */
	m_MMGR_FREE_CPA_CB(cb);

 cb_alloc_fail:


	return NCSCC_RC_FAILURE;
}
Ejemplo n.º 14
0
bool sysfTmrDestroy(void)
{
	SYSF_TMR *tmr;
	SYSF_TMR *free_tmr;
	SYSF_TMR_PAT_NODE *tmp = NULL;

	/* There is only ever one timer per instance */

	m_NCS_LOCK(&gl_tcb.safe.free_lock, NCS_LOCK_WRITE);

	gl_tcb.safe.dmy_free.next = NULL;

	m_NCS_UNLOCK(&gl_tcb.safe.free_lock, NCS_LOCK_WRITE);

	m_NCS_LOCK(&gl_tcb.safe.enter_lock, NCS_LOCK_WRITE);

	/* Create selection object */
	m_NCS_SEL_OBJ_CREATE(&tmr_destroy_syn_obj);

	tmr_destroying = true;

	m_NCS_SEL_OBJ_IND(&gl_tcb.sel_obj);

	/* Unlock the lock */
	m_NCS_UNLOCK(&gl_tcb.safe.enter_lock, NCS_LOCK_WRITE);	/* critical region END */

	/* Wait on Poll object */
	osaf_poll_one_fd(m_GET_FD_FROM_SEL_OBJ(tmr_destroy_syn_obj), 20000);

	m_NCS_LOCK(&gl_tcb.safe.enter_lock, NCS_LOCK_WRITE);
	tmr = &gl_tcb.safe.dmy_keep;
	while (tmr->keep != NULL) {
		free_tmr = tmr->keep;
		tmr->keep = tmr->keep->keep;
		m_NCS_MEM_FREE(free_tmr, NCS_MEM_REGION_PERSISTENT, NCS_SERVICE_ID_LEAP_TMR, 0);
	}
	while ((tmp = (SYSF_TMR_PAT_NODE *)ncs_patricia_tree_getnext(&gl_tcb.tmr_pat_tree, (uint8_t *)0)) != NULL) {
		ncs_patricia_tree_del(&gl_tcb.tmr_pat_tree, (NCS_PATRICIA_NODE *)tmp);
		m_NCS_MEM_FREE(tmp, NCS_MEM_REGION_PERSISTENT, NCS_SERVICE_ID_LEAP_TMR, 0);
	}

	ncs_patricia_tree_destroy(&gl_tcb.tmr_pat_tree);
	m_NCS_SEL_OBJ_DESTROY(&gl_tcb.sel_obj);

	/* Stop the dedicated thread that runs out of ncs_tmr_wait() */

	m_NCS_TASK_RELEASE(gl_tcb.p_tsk_hdl);

	tmr_destroying = false;

	m_NCS_SEL_OBJ_DESTROY(&tmr_destroy_syn_obj);

	m_NCS_UNLOCK(&gl_tcb.safe.enter_lock, NCS_LOCK_WRITE);	/* critical region END */

	/* don't destroy the lock (but remember that you could!).
	 * m_NCS_LOCK_DESTROY (&l_tcb.lock); 
	 */

	m_NCS_LOCK_DESTROY(&gl_tcb.safe.enter_lock);

	m_NCS_LOCK_DESTROY(&gl_tcb.safe.free_lock);

	ncs_tmr_create_done = false;

	return true;
}
Ejemplo n.º 15
0
/****************************************************************************
  Name          : mqa_create
 
  Description   : This routine creates & initializes the MQA control block.
 
  Arguments     : create_info - ptr to the create info
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
static uns32 mqa_create(NCS_LIB_CREATE *create_info)
{
	MQA_CB *cb = &mqa_cb;

	uns32 rc = NCSCC_RC_SUCCESS;
	/* validate create info */
	if (create_info == NULL)
		return NCSCC_RC_FAILURE;

	/* Register with Logging subsystem */
	mqa_flx_log_reg();

	memset(cb, 0, sizeof(MQA_CB));

	/* assign the MQA pool-id (used by hdl-mngr) */
	cb->pool_id = NCS_HM_POOL_ID_COMMON;

	/* create the association with hdl-mngr */
	if (!(cb->agent_handle_id = ncshm_create_hdl(cb->pool_id, NCS_SERVICE_ID_MQA, (NCSCONTEXT)cb))) {
		m_LOG_MQSV_A(MQA_CREATE_HANDLE_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__);
		goto error1;
	}

	m_LOG_MQSV_A(MQA_CREATE_HANDLE_SUCCESS, NCSFL_LC_MQSV_INIT, NCSFL_SEV_NOTICE, 1, __FILE__, __LINE__);
	/* everything went off well.. store the hdl in the global variable */
	gl_mqa_hdl = cb->agent_handle_id;

	/* get the process id */
	cb->process_id = getpid();

	/* initialize the mqa cb lock */
	if ((rc = m_NCS_LOCK_INIT(&cb->cb_lock)) != NCSCC_RC_SUCCESS) {
		m_LOG_MQSV_A(MQA_CB_LOCK_INIT_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__);
		goto error2;
	}
	m_LOG_MQSV_A(MQA_CB_LOCK_INIT_SUCCESS, NCSFL_LC_MQSV_INIT, NCSFL_SEV_NOTICE, rc, __FILE__, __LINE__);

	/* initialize the client tree */
	if ((rc = mqa_client_tree_init(cb)) != NCSCC_RC_SUCCESS) {
		m_LOG_MQSV_A(MQA_CLIENT_TREE_INIT_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__);
		goto error3;
	}

	m_LOG_MQSV_A(MQA_CLIENT_TREE_INIT_SUCCESS, NCSFL_LC_MQSV_INIT, NCSFL_SEV_NOTICE, rc, __FILE__, __LINE__);
	/* initialize the queue tree */
	if ((rc = mqa_queue_tree_init(cb)) != NCSCC_RC_SUCCESS) {
		m_LOG_MQSV_A(MQA_QUEUE_TREE_INIT_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__);
		goto error4;
	}
	m_LOG_MQSV_A(MQA_QUEUE_TREE_INIT_SUCCESS, NCSFL_LC_MQSV_INIT, NCSFL_SEV_NOTICE, rc, __FILE__, __LINE__);

	/* EDU initialisation */
	if ((rc = m_NCS_EDU_HDL_INIT(&cb->edu_hdl)) != NCSCC_RC_SUCCESS) {
		m_LOG_MQSV_A(MQA_EDU_HDL_INIT_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__);
		goto error5;
	}

	m_LOG_MQSV_A(MQA_EDU_HDL_INIT_SUCCESS, NCSFL_LC_MQSV_INIT, NCSFL_SEV_NOTICE, rc, __FILE__, __LINE__);
	/* register with MDS */
	if ((rc = mqa_mds_register(cb)) != NCSCC_RC_SUCCESS) {
		m_LOG_MQSV_A(MQA_MDS_REGISTER_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__);
		goto error6;
	} else
		m_LOG_MQSV_A(MQA_MDS_REGISTER_SUCCESS, NCSFL_LC_MQSV_INIT, NCSFL_SEV_INFO, rc, __FILE__, __LINE__);

	/* Update clm_node_joined flag to 1 */

	cb->clm_node_joined = 1;

	mqa_sync_with_mqd(cb);

	mqa_sync_with_mqnd(cb);

	/* initialize the timeout linked list */
	if ((rc = mqa_timer_table_init(cb)) != NCSCC_RC_SUCCESS) {
		m_LOG_MQSV_A(MQA_TIMER_TABLE_INIT_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__);
		goto error7;
	}

	if ((rc = mqa_asapi_register(cb)) != NCSCC_RC_SUCCESS) {
		m_LOG_MQSV_A(MQA_REGISTER_WITH_ASAPi_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__,
			     __LINE__);
		goto error8;
	}

	return NCSCC_RC_SUCCESS;

 error8:
	mqa_timer_table_destroy(cb);

 error7:
	/* MDS unregister. */
	mqa_mds_unregister(cb);

 error6:
	m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl);

 error5:
	/* delete the tree */
	mqa_queue_tree_destroy(cb);

 error4:
	/* delete the tree */
	mqa_client_tree_destroy(cb);
 error3:
	/* destroy the lock */
	m_NCS_LOCK_DESTROY(&cb->cb_lock);

 error2:
	/* remove the association with hdl-mngr */
	ncshm_destroy_hdl(NCS_SERVICE_ID_MQA, cb->agent_handle_id);
 error1:
	/* de register with the flex log */
	mqa_flx_log_dereg();

	return NCSCC_RC_FAILURE;
}
Ejemplo n.º 16
0
/****************************************************************************
  Name          : eda_create
 
  Description   : This routine creates & initializes the EDA control block.
 
  Arguments     : create_info - ptr to the create info
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
uns32 eda_create(NCS_LIB_CREATE *create_info)
{
	EDA_CB *cb = 0;
	uns32 rc = NCSCC_RC_SUCCESS;

	if (NULL == create_info)
		return NCSCC_RC_FAILURE;

	/* Register with the Logging subsystem */
	eda_flx_log_reg();

	/* allocate EDA cb */
	if (NULL == (cb = m_MMGR_ALLOC_EDA_CB)) {
		m_LOG_EDSV_A(EDA_MEMALLOC_FAILED, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__, 0);
		rc = NCSCC_RC_FAILURE;
		goto error;
	}

	memset(cb, 0, sizeof(EDA_CB));

	/* assign the EDA pool-id (used by hdl-mngr) */
	cb->pool_id = NCS_HM_POOL_ID_COMMON;

	/* create the association with hdl-mngr */
	if (0 == (cb->cb_hdl = ncshm_create_hdl(cb->pool_id, NCS_SERVICE_ID_EDA, (NCSCONTEXT)cb))) {
		m_LOG_EDSV_A(EDA_CB_HDL_CREATE_FAILED, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__, 0);
		rc = NCSCC_RC_FAILURE;
		goto error;
	}

	/* get the process id */
	cb->prc_id = getpid();

	/* initialize the eda cb lock */
	m_NCS_LOCK_INIT(&cb->cb_lock);
	m_NCS_LOCK_INIT(&cb->eds_sync_lock);

	/* Store the cb hdl in the global variable */
	gl_eda_hdl = cb->cb_hdl;

	/* register with MDS */
	if ((NCSCC_RC_SUCCESS != (rc = eda_mds_init(cb)))) {
		m_LOG_EDSV_A(EDA_MDS_INIT_FAILED, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__, 0);
		rc = NCSCC_RC_FAILURE;
		goto error;
	}

	eda_sync_with_eds(cb);
	cb->node_status = SA_CLM_NODE_JOINED;

	return rc;

 error:
	if (cb) {
		/* remove the association with hdl-mngr */
		if (cb->cb_hdl)
			ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, cb->cb_hdl);

		/* delete the eda init instances */
		eda_hdl_list_del(&cb->eda_init_rec_list);

		/* destroy the lock */
		m_NCS_LOCK_DESTROY(&cb->cb_lock);

		/* free the control block */
		m_MMGR_FREE_EDA_CB(cb);
	}
	return rc;
}
Ejemplo n.º 17
0
/****************************************************************************
  Name          : avnd_cb_destroy
 
  Description   : This routine destroys AvND control block.
 
  Arguments     : cb - ptr to AvND control block
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
uns32 avnd_cb_destroy(AVND_CB *cb)
{
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();

   /*** destroy all databases ***/

	/* We should delete external SU-SI first */
#ifdef NCS_AVND_MBCSV_CKPT
	if (NCSCC_RC_SUCCESS != (rc = avnd_ext_comp_data_clean_up(cb, TRUE)))
		goto done;
#endif
	/* destroy comp db */
	if (NCSCC_RC_SUCCESS != (rc = avnd_compdb_destroy(cb)))
		goto done;

	/* destroy su db */
	if (NCSCC_RC_SUCCESS != (rc = avnd_sudb_destroy(cb)))
		goto done;

	/* destroy healthcheck db */
	if (NCSCC_RC_SUCCESS != (rc = avnd_hcdb_destroy(cb)))
		goto done;

	/* destroy pg db */
	if (NCSCC_RC_SUCCESS != (rc = avnd_pgdb_destroy(cb)))
		goto done;

	/* Clean PID monitoring list */
	avnd_pid_mon_list_destroy(cb);

	/* destroy nodeid to mds dest db */
	if (NCSCC_RC_SUCCESS != (rc = avnd_nodeid_to_mdsdest_map_db_destroy(cb)))
		goto done;

	/* destroy available internode comp db */
	if (NCSCC_RC_SUCCESS != (rc = avnd_internode_avail_comp_db_destroy(cb)))
		goto done;

	/* destroy DND list */
	avnd_dnd_list_destroy(cb);

	/* destroy the lock */
	m_NCS_LOCK_DESTROY(&cb->lock);
	TRACE("Destroyed the cb lock");

	/* destroy the PID monitor lock */
	m_NCS_LOCK_DESTROY(&cb->mon_lock);

	/* detach & destroy AvND mailbox */
	rc = avnd_mbx_destroy(cb);
	if (NCSCC_RC_SUCCESS != rc)
		goto done;

	cb = NULL;
	TRACE("finalized the control block");

done:
	if (NCSCC_RC_SUCCESS != rc)
		LOG_ER("cleanup failed");
	TRACE_LEAVE();
	return rc;
}
Ejemplo n.º 18
0
/****************************************************************************
  Name          : ava_create
 
  Description   : This routine creates & initializes the AvA control block.
 
  Arguments     : create_info - ptr to the create info
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
uns32 ava_create(NCS_LIB_CREATE *create_info)
{
	AVA_CB *cb = 0;
	NCS_SEL_OBJ_SET set;
	uns32 rc = NCSCC_RC_SUCCESS, timeout = 300;
	EDU_ERR err;
	TRACE_ENTER();

	/* allocate AvA cb */
	if (!(cb = calloc(1, sizeof(AVA_CB)))) {
		LOG_ER("AVA Create: Calloc failed");
		rc = NCSCC_RC_FAILURE;
		goto error;
	}

	/* fetch the comp name from the env variable */
	if (getenv("SA_AMF_COMPONENT_NAME")) {
		if (strlen(getenv("SA_AMF_COMPONENT_NAME")) < SA_MAX_NAME_LENGTH) {
			strcpy((char *)cb->comp_name.value, getenv("SA_AMF_COMPONENT_NAME"));
			cb->comp_name.length = (uns16)strlen((char *)cb->comp_name.value);
			m_AVA_FLAG_SET(cb, AVA_FLAG_COMP_NAME);
			TRACE("Component name = %s",cb->comp_name.value);
		} else {
			TRACE_2("Length of SA_AMF_COMPONENT_NAME exceeds SA_MAX_NAME_LENGTH bytes");
			rc = NCSCC_RC_FAILURE;
			goto error;
		}
	}

	/* assign the AvA pool-id (used by hdl-mngr) */
	cb->pool_id = NCS_HM_POOL_ID_COMMON;

	/* create the association with hdl-mngr */
	if (!(cb->cb_hdl = ncshm_create_hdl(cb->pool_id, NCS_SERVICE_ID_AVA, (NCSCONTEXT)cb))) {
		LOG_ER("Unable to create handle for control block");
		rc = NCSCC_RC_FAILURE;
		goto error;
	}

	TRACE("Created handle for the control block");

	/* initialize the AvA cb lock */
	m_NCS_LOCK_INIT(&cb->lock);
	TRACE("Initialized the AVA control block lock");

	/* EDU initialisation */
	m_NCS_EDU_HDL_INIT(&cb->edu_hdl);
	TRACE("EDU Initialization success");

	rc = m_NCS_EDU_COMPILE_EDP(&cb->edu_hdl, avsv_edp_nda_msg, &err);

	if (rc != NCSCC_RC_SUCCESS) {
		TRACE_4("EDU Compilation failed");
		goto error;
	}

	/* create the sel obj (for mds sync) */
	m_NCS_SEL_OBJ_CREATE(&cb->sel_obj);

	/* initialize the hdl db */
	if (NCSCC_RC_SUCCESS != ava_hdl_init(&cb->hdl_db)) {
		TRACE_4("AVA Handles DB initialization failed");
		rc = NCSCC_RC_FAILURE;
		goto error;
	}
	TRACE("AVA Handles DB created successfully");

	m_NCS_SEL_OBJ_ZERO(&set);
	m_NCS_SEL_OBJ_SET(cb->sel_obj, &set);
	m_AVA_FLAG_SET(cb, AVA_FLAG_FD_VALID);

	/* register with MDS */
	if ((NCSCC_RC_SUCCESS != ava_mds_reg(cb))) {
		LOG_ER("AVA MDS Registration failed");
		rc = NCSCC_RC_FAILURE;
		goto error;
	}
	TRACE("AVA MDS Registration success");

	TRACE_1("Waiting on select till AMF Node Director is up");
	/* block until mds detects avnd */
	m_NCS_SEL_OBJ_SELECT(cb->sel_obj, &set, 0, 0, &timeout);

	/* reset the fd validity flag  */
	m_NCS_LOCK(&cb->lock, NCS_LOCK_WRITE);
	m_AVA_FLAG_RESET(cb, AVA_FLAG_FD_VALID);
	m_NCS_UNLOCK(&cb->lock, NCS_LOCK_WRITE);

	/* This sel obj is no more used */
	m_NCS_SEL_OBJ_DESTROY(cb->sel_obj);

	/* everything went off well.. store the cb hdl in the global variable */
	gl_ava_hdl = cb->cb_hdl;

	TRACE_LEAVE();
	return rc;

 error:
	if (cb) {
		/* remove the association with hdl-mngr */
		if (cb->cb_hdl)
			ncshm_destroy_hdl(NCS_SERVICE_ID_AVA, cb->cb_hdl);

		/* delete the hdl db */
		ava_hdl_del(cb);

		/* Flush the edu hdl */
		m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl);

		/* destroy the lock */
		m_NCS_LOCK_DESTROY(&cb->lock);

		/* free the control block */
		free(cb);
	}
	TRACE_LEAVE();
	return rc;
}
Ejemplo n.º 19
0
/****************************************************************************
  Name          : mqa_create
 
  Description   : This routine creates & initializes the MQA control block.
 
  Arguments     : create_info - ptr to the create info
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
static uint32_t mqa_create(NCS_LIB_CREATE *create_info)
{
	MQA_CB *cb = &mqa_cb;

	uint32_t rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();

	/* validate create info */
	if (create_info == NULL)
		return NCSCC_RC_FAILURE;

	memset(cb, 0, sizeof(MQA_CB));

	/* assign the MQA pool-id (used by hdl-mngr) */
	cb->pool_id = NCS_HM_POOL_ID_COMMON;

	/* create the association with hdl-mngr */
	if (!(cb->agent_handle_id = ncshm_create_hdl(cb->pool_id, NCS_SERVICE_ID_MQA, (NCSCONTEXT)cb))) {
		TRACE_2("Handle Registration Failed");
		return NCSCC_RC_FAILURE;
	}

	TRACE_1("Handle Registration Success");
	/* everything went off well.. store the hdl in the global variable */
	gl_mqa_hdl = cb->agent_handle_id;

	/* get the process id */
	cb->process_id = getpid();

	/* initialize the mqa cb lock */
	if ((rc = m_NCS_LOCK_INIT(&cb->cb_lock)) != NCSCC_RC_SUCCESS) {
		TRACE_2("Cotnrol Block Lock Initialisation Failed eith return value %d", rc);
		goto error1;
	}
	TRACE_1("Control Block lock initialization Success");

	/* initialize the client tree */
	if ((rc = mqa_client_tree_init(cb)) != NCSCC_RC_SUCCESS) {
		TRACE_2("FAILURE: Client database Initialization Failed");
		goto error2;
	}

	TRACE_1("Client Database Initialization Success");
	/* initialize the queue tree */
	if ((rc = mqa_queue_tree_init(cb)) != NCSCC_RC_SUCCESS) {
		TRACE_2("FAILURE: Queue database Initialization Failed");
		goto error3;
	}
	TRACE_1("Queue Database Initialization Success");

	/* EDU initialisation */
	if ((rc = m_NCS_EDU_HDL_INIT(&cb->edu_hdl)) != NCSCC_RC_SUCCESS) {
		TRACE_2("Edu Handle Initialization Failed");
		goto error4;
	}

	TRACE_1("EDU Handle Initialization Success");
	/* register with MDS */
	if ((rc = mqa_mds_register(cb)) != NCSCC_RC_SUCCESS) {
		TRACE_2("FAILURE: MDS registration Failed");
		goto error5;
	} else
		TRACE_1("MDS Registration Success");

	/* Update clm_node_joined flag to 1 */

	cb->clm_node_joined = 1;

	mqa_sync_with_mqd(cb);

	mqa_sync_with_mqnd(cb);

	/* initialize the timeout linked list */
	if ((rc = mqa_timer_table_init(cb)) != NCSCC_RC_SUCCESS) {
		TRACE_2("FAILURE: Tmr Initialization Failed");
		goto error6;
	}

	if ((rc = mqa_asapi_register(cb)) != NCSCC_RC_SUCCESS) {
		TRACE_2("FAILURE: Registration with ASAPi Failed");
		goto error7;
	}

	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;

 error7:
	mqa_timer_table_destroy(cb);

 error6:
	/* MDS unregister. */
	mqa_mds_unregister(cb);

 error5:
	m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl);

 error4:
	/* delete the tree */
	mqa_queue_tree_destroy(cb);

 error3:
	/* delete the tree */
	mqa_client_tree_destroy(cb);
 error2:
	/* destroy the lock */
	m_NCS_LOCK_DESTROY(&cb->cb_lock);

 error1:
	/* remove the association with hdl-mngr */
	ncshm_destroy_hdl(NCS_SERVICE_ID_MQA, cb->agent_handle_id);

	return NCSCC_RC_FAILURE;
}
Ejemplo n.º 20
0
/****************************************************************************
  Name          : eda_create

  Description   : This routine creates & initializes the EDA control block.

  Arguments     : create_info - ptr to the create info

  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE

  Notes         : None
******************************************************************************/
uint32_t eda_create(NCS_LIB_CREATE *create_info)
{
    EDA_CB *cb = 0;
    uint32_t rc = NCSCC_RC_SUCCESS;
    TRACE_ENTER();

    if (NULL == create_info) {
        TRACE_LEAVE2("create_info is NULL");
        return NCSCC_RC_FAILURE;
    }

    /* allocate EDA cb */
    if (NULL == (cb = m_MMGR_ALLOC_EDA_CB)) {
        TRACE_4("malloc failed");
        rc = NCSCC_RC_FAILURE;
        goto error;
    }

    memset(cb, 0, sizeof(EDA_CB));

    /* assign the EDA pool-id (used by hdl-mngr) */
    cb->pool_id = NCS_HM_POOL_ID_COMMON;

    /* create the association with hdl-mngr */
    if (0 == (cb->cb_hdl = ncshm_create_hdl(cb->pool_id, NCS_SERVICE_ID_EDA, (NCSCONTEXT)cb))) {
        TRACE_4("create handle failed");
        rc = NCSCC_RC_FAILURE;
        goto error;
    }

    /* get the process id */
    cb->prc_id = getpid();

    /* initialize the eda cb lock */
    m_NCS_LOCK_INIT(&cb->cb_lock);
    m_NCS_LOCK_INIT(&cb->eds_sync_lock);

    /* Store the cb hdl in the global variable */
    gl_eda_hdl = cb->cb_hdl;

    TRACE_1("global eda library handle is: %u", gl_eda_hdl);

    /* register with MDS */
    if ((NCSCC_RC_SUCCESS != (rc = eda_mds_init(cb)))) {
        TRACE_4("mds init failed");
        rc = NCSCC_RC_FAILURE;
        goto error;
    }

    eda_sync_with_eds(cb);
    cb->node_status = SA_CLM_NODE_JOINED;
    TRACE_LEAVE2("Default local node membership status: %u", cb->node_status);
    return rc;

error:
    if (cb) {
        /* remove the association with hdl-mngr */
        if (cb->cb_hdl)
            ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, cb->cb_hdl);

        /* delete the eda init instances */
        eda_hdl_list_del(&cb->eda_init_rec_list);

        /* destroy the lock */
        m_NCS_LOCK_DESTROY(&cb->cb_lock);

        /* free the control block */
        m_MMGR_FREE_EDA_CB(cb);
    }
    TRACE_LEAVE();
    return rc;
}