Пример #1
0
/****************************************************************************
  Name          : avnd_ext_intf_destroy
 
  Description   : This routine destroys external interfaces (logging service
                  being the exception).
 
  Arguments     : cb - ptr to AvND control block
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
uns32 avnd_ext_intf_destroy(AVND_CB *cb)
{
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();

	/* MDS unregistration */
	rc = avnd_mds_unreg(cb);
	if (NCSCC_RC_SUCCESS != rc)
		goto done;

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

	m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl_avnd);

	m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl_ava);

	/* NTFA Finalize */
	rc = saNtfFinalize(cb->ntfHandle);
	if (rc != SA_AIS_OK) {
		LOG_ER("saNtfFinalize Failed (%u)", rc);
	}
 done:
	TRACE_LEAVE();
	return rc;
}
Пример #2
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;
}
Пример #3
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;
}
Пример #4
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;
}
Пример #5
0
/****************************************************************************
 * Name          : glnd_cb_destroy
 *
 * Description   : Destroy the CB 
 *
 * Arguments     : glnd_cb  - GLND control block pointer.
 *
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
 *
 * Notes         : None.
 *****************************************************************************/
uns32 glnd_cb_destroy(GLND_CB *glnd_cb)
{

	GLND_AGENT_INFO *agent_info;

	/* destroy the handle */
	if (glnd_cb->cb_hdl_id) {
		m_GLND_GIVEUP_GLND_CB;
		ncshm_destroy_hdl(NCS_SERVICE_ID_GLND, glnd_cb->cb_hdl_id);
	}

	/* detach the mail box */
	if (m_NCS_IPC_DETACH(&glnd_cb->glnd_mbx, glnd_cleanup_mbx, glnd_cb) != NCSCC_RC_SUCCESS)
		return NCSCC_RC_FAILURE;

	/* delete the mailbox */
	if (m_NCS_IPC_RELEASE(&glnd_cb->glnd_mbx, NULL) != NCSCC_RC_SUCCESS)
		return NCSCC_RC_FAILURE;

	/* delete all the internal structures */
	/* delete the trees */
	for (agent_info = (GLND_AGENT_INFO *)ncs_patricia_tree_getnext(&glnd_cb->glnd_agent_tree, (uns8 *)0);
	     agent_info != NULL;
	     agent_info = (GLND_AGENT_INFO *)ncs_patricia_tree_getnext(&glnd_cb->glnd_agent_tree, (uns8 *)0)) {
		glnd_agent_node_del(glnd_cb, agent_info);
	}
	ncs_patricia_tree_destroy(&glnd_cb->glnd_agent_tree);
	ncs_patricia_tree_destroy(&glnd_cb->glnd_client_tree);
	ncs_patricia_tree_destroy(&glnd_cb->glnd_res_tree);

	/* deresigter with the MDS */
	glnd_mds_unregister(glnd_cb);

	/* EDU cleanup */
	m_NCS_EDU_HDL_FLUSH(&glnd_cb->glnd_edu_hdl);

	/* free the control block */
	m_MMGR_FREE_GLND_CB(glnd_cb);

	/* deregister with the log service */
	glnd_flx_log_dereg();
	/* reset the global cb handle */
	gl_glnd_hdl = 0;
	return (NCSCC_RC_SUCCESS);
}
Пример #6
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;
}
Пример #7
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;
}
Пример #8
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;
}
Пример #9
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;
}
Пример #10
0
/****************************************************************************
 * Name          : gld_se_lib_init
 *
 * Description   : Invoked to Initialize the GLD
 *                 
 *
 * Arguments     : 
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE..
 *
 * Notes         : None.
 *****************************************************************************/
uns32 gld_se_lib_init(NCS_LIB_REQ_INFO *req_info)
{
	GLSV_GLD_CB *gld_cb;
	SaAisErrorT amf_error;
	uns32 res = NCSCC_RC_SUCCESS;
	SaAmfHealthcheckKeyT Healthy;
	int8 *health_key;

	/* Register with Logging subsystem */
	if (NCS_GLSV_LOG == 1)
		gld_flx_log_reg();

	/* Allocate and initialize the control block */
	gld_cb = m_MMGR_ALLOC_GLSV_GLD_CB;

	if (gld_cb == NULL) {
		m_LOG_GLD_MEMFAIL(GLD_CB_ALLOC_FAILED, __FILE__, __LINE__);
		return NCSCC_RC_FAILURE;
	}
	memset(gld_cb, 0, sizeof(GLSV_GLD_CB));

	/* TBD- Pool id is to be set */
	gl_gld_hdl = gld_cb->my_hdl = ncshm_create_hdl(gld_cb->hm_poolid, NCS_SERVICE_ID_GLD, (NCSCONTEXT)gld_cb);
	if (0 == gld_cb->my_hdl) {
		m_LOG_GLD_HEADLINE(GLD_CREATE_HANDLE_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0);
		m_MMGR_FREE_GLSV_GLD_CB(gld_cb);
		return NCSCC_RC_FAILURE;
	}

	/* Initialize the cb parameters */
	if (gld_cb_init(gld_cb) != NCSCC_RC_SUCCESS) {
		m_MMGR_FREE_GLSV_GLD_CB(gld_cb);
		return NCSCC_RC_FAILURE;
	}

	/* Initialize amf framework */
	if (gld_amf_init(gld_cb) != NCSCC_RC_SUCCESS) {
		m_LOG_GLD_SVC_PRVDR(GLD_AMF_INIT_ERROR, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		m_MMGR_FREE_GLSV_GLD_CB(gld_cb);
		return NCSCC_RC_FAILURE;
	}
	m_LOG_GLD_SVC_PRVDR(GLD_AMF_INIT_SUCCESS, NCSFL_SEV_INFO, __FILE__, __LINE__);

	/* Bind to MDS */
	if (gld_mds_init(gld_cb) != NCSCC_RC_SUCCESS) {
		saAmfFinalize(gld_cb->amf_hdl);
		m_MMGR_FREE_GLSV_GLD_CB(gld_cb);
		m_LOG_GLD_SVC_PRVDR(GLD_MDS_INSTALL_FAIL, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		return NCSCC_RC_FAILURE;
	} else
		m_LOG_GLD_SVC_PRVDR(GLD_MDS_INSTALL_SUCCESS, NCSFL_SEV_INFO, __FILE__, __LINE__);

	/*   Initialise with the MBCSV service  */
	if (glsv_gld_mbcsv_register(gld_cb) != NCSCC_RC_SUCCESS) {
		m_LOG_GLD_MBCSV(GLD_MBCSV_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		gld_mds_shut(gld_cb);
		saAmfFinalize(gld_cb->amf_hdl);
		m_MMGR_FREE_GLSV_GLD_CB(gld_cb);
		return NCSCC_RC_FAILURE;

	} else {
		m_LOG_GLD_MBCSV(GLD_MBCSV_INIT_SUCCESS, NCSFL_SEV_INFO, __FILE__, __LINE__);

	}

	/* register glsv with imm */
	amf_error = gld_imm_init(gld_cb);
	if (amf_error != SA_AIS_OK) {
		glsv_gld_mbcsv_unregister(gld_cb);
		gld_mds_shut(gld_cb);
		saAmfFinalize(gld_cb->amf_hdl);
		m_MMGR_FREE_GLSV_GLD_CB(gld_cb);
		gld_log(NCSFL_SEV_ERROR, "Imm Init Failed %u\n", amf_error);
		return NCSCC_RC_FAILURE;
	}

	/* TASK CREATION AND INITIALIZING THE MAILBOX */
	if ((m_NCS_IPC_CREATE(&gld_cb->mbx) != NCSCC_RC_SUCCESS) ||
	    (m_NCS_IPC_ATTACH(&gld_cb->mbx) != NCSCC_RC_SUCCESS) ||
	    (m_NCS_TASK_CREATE((NCS_OS_CB)gld_main_process,
			       &gld_cb->mbx, "GLD", m_GLD_TASK_PRIORITY,
			       m_GLD_STACKSIZE,
			       &gld_cb->task_hdl) != NCSCC_RC_SUCCESS) ||
	    (m_NCS_TASK_START(gld_cb->task_hdl) != NCSCC_RC_SUCCESS)) {
		m_LOG_GLD_HEADLINE(GLD_IPC_TASK_INIT, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0);
		saImmOiFinalize(gld_cb->immOiHandle);
		glsv_gld_mbcsv_unregister(gld_cb);
		gld_mds_shut(gld_cb);
		saAmfFinalize(gld_cb->amf_hdl);
		m_NCS_TASK_RELEASE(gld_cb->task_hdl);
		m_NCS_IPC_RELEASE(&gld_cb->mbx, NULL);
		m_MMGR_FREE_GLSV_GLD_CB(gld_cb);
		return (NCSCC_RC_FAILURE);
	}

	m_NCS_EDU_HDL_INIT(&gld_cb->edu_hdl);

	/* register GLD component with AvSv */
	amf_error = saAmfComponentRegister(gld_cb->amf_hdl, &gld_cb->comp_name, (SaNameT *)NULL);
	if (amf_error != SA_AIS_OK) {
		m_LOG_GLD_SVC_PRVDR(GLD_AMF_REG_ERROR, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		m_NCS_EDU_HDL_FLUSH(&gld_cb->edu_hdl);
		m_NCS_TASK_RELEASE(gld_cb->task_hdl);
		m_NCS_IPC_RELEASE(&gld_cb->mbx, NULL);
		saImmOiFinalize(gld_cb->immOiHandle);
		glsv_gld_mbcsv_unregister(gld_cb);
		gld_mds_shut(gld_cb);
		saAmfFinalize(gld_cb->amf_hdl);
		m_MMGR_FREE_GLSV_GLD_CB(gld_cb);
		return NCSCC_RC_FAILURE;
	} else
		m_LOG_GLD_SVC_PRVDR(GLD_AMF_REG_SUCCESS, NCSFL_SEV_INFO, __FILE__, __LINE__);

   /** start the AMF health check **/
	memset(&Healthy, 0, sizeof(Healthy));
	health_key = (int8 *)getenv("GLSV_ENV_HEALTHCHECK_KEY");
	if (health_key == NULL) {
		if (strlen("A1B2") < sizeof(Healthy.key))
			strncpy((char *)Healthy.key, "A1B2", sizeof(Healthy.key));
		m_LOG_GLD_HEADLINE(GLD_HEALTH_KEY_DEFAULT_SET, NCSFL_SEV_INFO, __FILE__, __LINE__, 0);
	} else {
		if (strlen((char *)health_key) < sizeof(Healthy.key))
			strncpy((char *)Healthy.key, (char *)health_key, SA_AMF_HEALTHCHECK_KEY_MAX - 1);
	}
	Healthy.keyLen = strlen((char *)Healthy.key);

	amf_error = saAmfHealthcheckStart(gld_cb->amf_hdl, &gld_cb->comp_name, &Healthy,
					  SA_AMF_HEALTHCHECK_AMF_INVOKED, SA_AMF_COMPONENT_FAILOVER);
	if (amf_error != SA_AIS_OK) {
		m_LOG_GLD_SVC_PRVDR(GLD_AMF_HLTH_CHK_START_FAIL, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		saAmfComponentUnregister(gld_cb->amf_hdl, &gld_cb->comp_name, (SaNameT *)NULL);
		m_NCS_EDU_HDL_FLUSH(&gld_cb->edu_hdl);
		m_NCS_TASK_RELEASE(gld_cb->task_hdl);
		m_NCS_IPC_RELEASE(&gld_cb->mbx, NULL);
		saImmOiFinalize(gld_cb->immOiHandle);
		glsv_gld_mbcsv_unregister(gld_cb);
		gld_mds_shut(gld_cb);
		saAmfFinalize(gld_cb->amf_hdl);
		m_MMGR_FREE_GLSV_GLD_CB(gld_cb);
	} else
		m_LOG_GLD_SVC_PRVDR(GLD_AMF_HLTH_CHK_START_DONE, NCSFL_SEV_INFO, __FILE__, __LINE__);

	return (res);
}
Пример #11
0
/****************************************************************************
 * Name          : eds_se_lib_init
 *
 * Description   : Invoked to Initialize the EDS
 *                 
 *
 * Arguments     : 
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE..
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t eds_se_lib_init(NCS_LIB_REQ_INFO *req_info)
{
	EDS_CB *eds_cb;
	uint32_t rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();


	/* Allocate and initialize the control block */
	if (NULL == (eds_cb = m_MMGR_ALLOC_EDS_CB)) {
		LOG_CR("malloc failed for control block");
		TRACE_LEAVE();
		return NCSCC_RC_FAILURE;
	}
	memset(eds_cb, '\0', sizeof(EDS_CB));

	/* Obtain the hdl for EDS_CB from hdl-mgr */
	gl_eds_hdl = eds_cb->my_hdl = ncshm_create_hdl(1, NCS_SERVICE_ID_EDS, (NCSCONTEXT)eds_cb);

	if (0 == eds_cb->my_hdl) {
		LOG_ER("Handle create failed for global eds handle");
		ncshm_destroy_hdl(NCS_SERVICE_ID_EDS, gl_eds_hdl);
		gl_eds_hdl = 0;
		m_MMGR_FREE_EDS_CB(eds_cb);
		TRACE_LEAVE();
		return NCSCC_RC_FAILURE;
	}

	/* initialize the eds cb lock */
	m_NCS_LOCK_INIT(&eds_cb->cb_lock);

	/* Initialize eds control block */
	if (NCSCC_RC_SUCCESS != (rc = eds_cb_init(eds_cb))) {
		/* Destroy the hdl for this CB */
		ncshm_destroy_hdl(NCS_SERVICE_ID_EDS, gl_eds_hdl);
		gl_eds_hdl = 0;
		/* clean up the CB */
		m_MMGR_FREE_EDS_CB(eds_cb);
		/* log the error */
		TRACE_4("EDS control block init failed");
		TRACE_LEAVE();
		return rc;
	}


	m_NCS_EDU_HDL_INIT(&eds_cb->edu_hdl);

	/* Create the mbx to communicate with the EDS thread */
	if (NCSCC_RC_SUCCESS != (rc = m_NCS_IPC_CREATE(&eds_cb->mbx))) {
		LOG_ER("EDS IPC mailbox create failed");
		/* Release EDU handle */
		m_NCS_EDU_HDL_FLUSH(&eds_cb->edu_hdl);
		/* Destroy the hdl for this CB */
		ncshm_destroy_hdl(NCS_SERVICE_ID_EDS, gl_eds_hdl);
		gl_eds_hdl = 0;
		/* Free the control block */
		m_MMGR_FREE_EDS_CB(eds_cb);
		TRACE_LEAVE();
		return rc;
	}
	/* Attach the IPC to the created thread */
	m_NCS_IPC_ATTACH(&eds_cb->mbx);

	/* Bind to MDS */
	if (NCSCC_RC_SUCCESS != (rc = eds_mds_init(eds_cb))) {
		TRACE_4("eds mds init failed");
		m_NCS_IPC_RELEASE(&eds_cb->mbx, NULL);
		/* Release EDU handle */
		m_NCS_EDU_HDL_FLUSH(&eds_cb->edu_hdl);
		ncshm_destroy_hdl(NCS_SERVICE_ID_EDS, gl_eds_hdl);
		gl_eds_hdl = 0;
		m_MMGR_FREE_EDS_CB(eds_cb);
		TRACE_LEAVE();
		return rc;
	}

	/* Initialize and Register with CLM */
	rc = eds_clm_init(eds_cb);
	if (rc != SA_AIS_OK) {
		TRACE_4("CLM Init failed. Exiting");
		exit(EXIT_FAILURE);
	}

	/* Initialize and Register with AMF */
	rc = eds_amf_register(eds_cb);
	if (rc != NCSCC_RC_SUCCESS) {
		LOG_ER("AMF Init failed: Exiting.");
		exit(EXIT_FAILURE);
	}

	/* Initialize mbcsv interface */
	if (NCSCC_RC_SUCCESS != (rc = eds_mbcsv_init(eds_cb))) {
		LOG_ER("eds mbcsv init failed");
		/* Log it */
	}

	TRACE("eds init done.");
	TRACE_LEAVE();
	return (rc);
}
Пример #12
0
/****************************************************************************
 * Name          : glnd_cb_create
 *
 * Description   : This will create the CB and create the internal structures
 *
 * Arguments     : pool id - pool id for the handle manager
 *
 * Return Values : GLND CB Pointer
 *
 * Notes         : None.
 *****************************************************************************/
GLND_CB *glnd_cb_create(uns32 pool_id)
{
	GLND_CB *glnd_cb = NULL;
	NCS_PATRICIA_PARAMS params = { 0 };
	SaAmfHealthcheckKeyT healthy;
	int8 *health_key = NULL;
	SaAisErrorT amf_error;

	/* register with the Log service */
	glnd_flx_log_reg();

	/* allocate the memory */
	glnd_cb = m_MMGR_ALLOC_GLND_CB;

	if (!glnd_cb) {
		m_LOG_GLND_MEMFAIL(GLND_CB_ALLOC_FAILED, __FILE__, __LINE__);
		glnd_flx_log_dereg();
		return NULL;
	}

	memset(glnd_cb, 0, sizeof(GLND_CB));
	glnd_cb->pool_id = pool_id;

	/* create the handle */
	glnd_cb->cb_hdl_id = ncshm_create_hdl((uns8)pool_id, NCS_SERVICE_ID_GLND, (NCSCONTEXT)glnd_cb);
	if (!glnd_cb->cb_hdl_id) {
		m_LOG_GLND_HEADLINE(GLND_CB_TAKE_HANDLE_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		goto hdl_err;
	}

	/* create the internal strucutures */
	/* create the client Tree */
	params.key_size = sizeof(SaLckHandleT);
	params.info_size = 0;
	if ((ncs_patricia_tree_init(&glnd_cb->glnd_client_tree, &params)) != NCSCC_RC_SUCCESS) {
		m_LOG_GLND_HEADLINE(GLND_CLIENT_TREE_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		goto client_err;
	}

	/* create the agent tree */
	params.key_size = sizeof(MDS_DEST);
	params.info_size = 0;
	if ((ncs_patricia_tree_init(&glnd_cb->glnd_agent_tree, &params)) != NCSCC_RC_SUCCESS) {
		m_LOG_GLND_HEADLINE(GLND_AGENT_TREE_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		goto agent_err;
	}

	/* create the Resource tree */
	params.key_size = sizeof(SaLckResourceIdT);
	params.info_size = 0;
	if ((ncs_patricia_tree_init(&glnd_cb->glnd_res_tree, &params)) != NCSCC_RC_SUCCESS) {
		m_LOG_GLND_HEADLINE(GLND_RSC_TREE_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		goto res_err;
	}

	/* create the mail box and attach it */
	if (m_NCS_IPC_CREATE(&glnd_cb->glnd_mbx) != NCSCC_RC_SUCCESS) {
		m_LOG_GLND_HEADLINE(GLND_IPC_CREATE_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		goto mbx_create_err;
	}

	if (m_NCS_IPC_ATTACH(&glnd_cb->glnd_mbx) != NCSCC_RC_SUCCESS) {
		m_LOG_GLND_HEADLINE(GLND_IPC_ATTACH_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		goto mbx_attach_err;
	}

	/* EDU initialisation */
	m_NCS_EDU_HDL_INIT(&glnd_cb->glnd_edu_hdl);

	/* resigter with the MDS */
	if (glnd_mds_register(glnd_cb) != NCSCC_RC_SUCCESS) {
		m_LOG_GLND_HEADLINE(GLND_MDS_REGISTER_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		goto mds_err;
	} else
		m_LOG_GLND_HEADLINE(GLND_MDS_REGISTER_SUCCESS, NCSFL_SEV_NOTICE, __FILE__, __LINE__);

	/* Initialise with the AMF service */
	if (glnd_amf_init(glnd_cb) != NCSCC_RC_SUCCESS) {
		m_LOG_GLND_HEADLINE(GLND_AMF_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		goto amf_init_err;
	} else
		m_LOG_GLND_HEADLINE(GLND_AMF_INIT_SUCCESS, NCSFL_SEV_NOTICE, __FILE__, __LINE__);

	/* register with the AMF service */
	if (glnd_amf_register(glnd_cb) != NCSCC_RC_SUCCESS) {
		m_LOG_GLND_HEADLINE(GLND_AMF_REGISTER_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		goto amf_reg_err;
	} else
		m_LOG_GLND_HEADLINE(GLND_AMF_REGISTER_SUCCESS, NCSFL_SEV_NOTICE, __FILE__, __LINE__);

	/* everything went off well.. store the hdl in the global variable */
	gl_glnd_hdl = glnd_cb->cb_hdl_id;

	/*   start the AMF Health Check  */

	memset(&healthy, 0, sizeof(healthy));

	health_key = (int8 *)getenv("GLSV_ENV_HEALTHCHECK_KEY");
	if (health_key == NULL) {
		if (strlen("A1B2") < sizeof(healthy.key))
			strncpy((char *)healthy.key, "A1B2", sizeof(healthy.key));
		/* TBD Log the info */
	} else {
		if (strlen((char *)health_key) <= sizeof(healthy.key))
			strncpy((char *)healthy.key, (char *)health_key, SA_AMF_HEALTHCHECK_KEY_MAX - 1);
	}
	healthy.keyLen = strlen((char *)healthy.key);

	amf_error = saAmfHealthcheckStart(glnd_cb->amf_hdl, &glnd_cb->comp_name, &healthy,
					  SA_AMF_HEALTHCHECK_AMF_INVOKED, SA_AMF_COMPONENT_RESTART);
	if (amf_error != SA_AIS_OK) {
		m_LOG_GLND_HEADLINE(GLND_AMF_HEALTHCHECK_START_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__);
	} else
		m_LOG_GLND_HEADLINE(GLND_AMF_HEALTHCHECK_START_SUCCESS, NCSFL_SEV_NOTICE, __FILE__, __LINE__);

	if (glnd_cb->node_state != GLND_CLIENT_INFO_GET_STATE) {
		TRACE("setting the state as  GLND_OPERATIONAL_STATE");
		/* GLND HAS STRTED */
		glnd_cb->node_state = GLND_OPERATIONAL_STATE;

	}

	/*create a shared memory segment to Checkpint Resource info, lck_info & backup_event info */
	if (glnd_shm_create(glnd_cb) != NCSCC_RC_SUCCESS)
		goto glnd_shm_create_fail;

	return glnd_cb;
 glnd_shm_create_fail:
	glnd_amf_deregister(glnd_cb);
 amf_reg_err:
	glnd_amf_de_init(glnd_cb);
 amf_init_err:
	glnd_mds_unregister(glnd_cb);
 mds_err:
	m_NCS_EDU_HDL_FLUSH(&glnd_cb->glnd_edu_hdl);
	m_NCS_IPC_DETACH(&glnd_cb->glnd_mbx, glnd_cleanup_mbx, glnd_cb);
 mbx_attach_err:
	m_NCS_IPC_RELEASE(&glnd_cb->glnd_mbx, NULL);
 mbx_create_err:
	ncs_patricia_tree_destroy(&glnd_cb->glnd_res_tree);
 res_err:
	ncs_patricia_tree_destroy(&glnd_cb->glnd_agent_tree);
 agent_err:
	ncs_patricia_tree_destroy(&glnd_cb->glnd_client_tree);
 client_err:
	ncshm_destroy_hdl(NCS_SERVICE_ID_GLND, glnd_cb->cb_hdl_id);
 hdl_err:
	glnd_flx_log_dereg();
	/* free the control block */
	m_MMGR_FREE_GLND_CB(glnd_cb);

	return NULL;
}