예제 #1
0
/****************************************************************************
 * Function Name: ncs_tmr_stop_v2
 *
 * Purpose:   Mark this timer as DORMANT  
 *            if timer is already in DORMANT state returns 
 *            NCSCC_RC_TMR_STOPPED
 *
 * Arguments:
 *               tmrID     :    tmr id
 *               **tmr_arg :    void double pointer  
 * Return values:
 *     NCSCC_RC_FAILURE    :    Any validations fails (or)
 *                                If this timer is in CREATE or DESTROY state
 *     NCSCC_RC_SUCCESS    :    This timer START state and is set to DORMANT state 
 *     NCSCC_RC_TMR_STOPPED:    If the timer is already in DORMANT state 
 *
 ****************************************************************************/
uint32_t ncs_tmr_stop_v2(tmr_t tmrID, void **o_tmr_arg)
{
	SYSF_TMR *tmr;

	if (((tmr = (SYSF_TMR *)tmrID) == NULL) || (tmr_destroying == true) || (o_tmr_arg == NULL))
		return NCSCC_RC_FAILURE;

	m_NCS_LOCK(&gl_tcb.safe.enter_lock, NCS_LOCK_WRITE);	/* critical region START */

	/* Test tmr is already expired */
	if (TMR_TEST_STATE(tmr, TMR_STATE_DORMANT)) {
		m_NCS_UNLOCK(&gl_tcb.safe.enter_lock, NCS_LOCK_WRITE);	/* critical region END */
		return NCSCC_RC_TMR_STOPPED;
	} else if (TMR_TEST_STATE(tmr, TMR_STATE_START)) {
#if ENABLE_SYSLOG_TMR_STATS
		gl_tcb.stats.cnt--;
		if (gl_tcb.stats.cnt == 0) {
			syslog(LOG_INFO, "NO Timers Active STOP_V2 PID %u \n", getpid());
		}
#endif
		/* set tmr to DORMANT state */
		TMR_SET_STATE(tmr, TMR_STATE_DORMANT);
	} else {
		m_NCS_UNLOCK(&gl_tcb.safe.enter_lock, NCS_LOCK_WRITE);	/* critical region END */
		return NCSCC_RC_FAILURE;
	}

	*o_tmr_arg = tmr->tmrUarg;

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

	return NCSCC_RC_SUCCESS;
}
예제 #2
0
/***********************************************************************//**
* @brief	This function is for PLMA to sync with PLMS when it gets 
*		MDS callback.
*
* @return	Returns nothing.
***************************************************************************/
void plma_sync_with_plms()
{
	PLMA_CB *cb = plma_ctrlblk;
	
	TRACE_ENTER();
	
	m_NCS_LOCK(&cb->cb_lock, NCS_LOCK_WRITE);

	if (cb->plms_svc_up) {
		TRACE("Plms is up");
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
		return;
	}

	cb->plms_sync_awaited = true;
	m_NCS_SEL_OBJ_CREATE(&cb->sel_obj);
	m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);

	/** Await indication from MDS saying PLMS is up */
	osaf_poll_one_fd(m_GET_FD_FROM_SEL_OBJ(cb->sel_obj), 30000);

	/* Destroy the sync - object */
	m_NCS_LOCK(&cb->cb_lock, NCS_LOCK_WRITE);

	cb->plms_sync_awaited = false;
	m_NCS_SEL_OBJ_DESTROY(cb->sel_obj);

	m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);

	TRACE_LEAVE();
	return;
}
예제 #3
0
/**************************************************************************
 Function: plms_amf_register

 Purpose:  Function which registers PLMS with AMF.  

 Input:    Pointer to the PLMS control block. 

 Returns:  NCSCC_RC_SUCCESSS/NCSCC_RC_FAILURE

 Notes:  Here we call plms_amf_init after reading the component name file and
         setting the environment varaiable in our own context.
         Proceed to register with AMF, since it has come up. 
**************************************************************************/
SaUint32T plms_amf_register()
{

	SaAisErrorT error;
	uint32_t rc = NCSCC_RC_SUCCESS;
	PLMS_CB * cb = plms_cb;

	m_NCS_LOCK(&cb->cb_lock, NCS_LOCK_WRITE);

	/* Initialize amf framework for hc interface */
	if ((rc = plms_amf_init()) != NCSCC_RC_SUCCESS) {
		LOG_ER("AMF init failed");
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
		return NCSCC_RC_FAILURE;
	}

	LOG_IN("AMF init SUCCESS");
	/* register PLMS component with AvSv */
	error = saAmfComponentRegister(cb->amf_hdl, &cb->comp_name, (SaNameT *)NULL);
	if (error != SA_AIS_OK) {
		LOG_ER("AMF Component Register failed");
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
		return NCSCC_RC_FAILURE;
	}
	LOG_IN("AMF Component Register SUCCESS");
	if (NCSCC_RC_SUCCESS != (rc = plms_healthcheck_start())) {
		LOG_ER("PLMS Health Check Start failed");
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
		return NCSCC_RC_FAILURE;
	}
	LOG_IN("PLMS Health Check Started Successfully SUCCESS");
	m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);

	return NCSCC_RC_SUCCESS;
}
예제 #4
0
/********************************************************************
 Name    :  mqa_sync_with_mqnd

 Description : This is for MQA to sync with MQND when it gets MDS callback
 
**********************************************************************/
static void mqa_sync_with_mqnd(MQA_CB *cb)
{
	NCS_SEL_OBJ_SET set;
	uns32 timeout = 3000;

	m_NCS_LOCK(&cb->mqnd_sync_lock, NCS_LOCK_WRITE);

	if (cb->is_mqnd_up) {
		m_LOG_MQSV_A(MQA_MQND_ALREADY_UP, NCSFL_LC_MQSV_INIT, NCSFL_SEV_INFO, 1, __FILE__, __LINE__);
		m_NCS_UNLOCK(&cb->mqnd_sync_lock, NCS_LOCK_WRITE);
		return;
	}

	cb->mqnd_sync_awaited = TRUE;
	m_NCS_SEL_OBJ_CREATE(&cb->mqnd_sync_sel);
	m_NCS_UNLOCK(&cb->mqnd_sync_lock, NCS_LOCK_WRITE);

	/* Await indication from MDS saying MQND is up */
	m_NCS_SEL_OBJ_ZERO(&set);
	m_NCS_SEL_OBJ_SET(cb->mqnd_sync_sel, &set);
	m_NCS_SEL_OBJ_SELECT(cb->mqnd_sync_sel, &set, 0, 0, &timeout);

	/* Destroy the sync - object */
	m_NCS_LOCK(&cb->mqnd_sync_lock, NCS_LOCK_WRITE);

	cb->mqnd_sync_awaited = FALSE;
	m_NCS_SEL_OBJ_DESTROY(cb->mqnd_sync_sel);

	m_NCS_UNLOCK(&cb->mqnd_sync_lock, NCS_LOCK_WRITE);
	m_LOG_MQSV_A(MQA_SYNC_WITH_MQND_UP, NCSFL_LC_MQSV_INIT, NCSFL_SEV_INFO, 1, __FILE__, __LINE__);
	return;
}
예제 #5
0
/********************************************************************
 Name    :  cpa_sync_with_cpnd

 Description : This is for CPA to sync with CPND when it gets MDS callback
 
**********************************************************************/
void cpa_sync_with_cpnd(CPA_CB *cb)
{
	m_NCS_LOCK(&cb->cpnd_sync_lock, NCS_LOCK_WRITE);

	if (cb->is_cpnd_up) {
		m_NCS_UNLOCK(&cb->cpnd_sync_lock, NCS_LOCK_WRITE);
		return;
	}

	cb->cpnd_sync_awaited = true;
	m_NCS_SEL_OBJ_CREATE(&cb->cpnd_sync_sel);
	m_NCS_UNLOCK(&cb->cpnd_sync_lock, NCS_LOCK_WRITE);

	/* Await indication from MDS saying CPND is up */
	osaf_poll_one_fd(m_GET_FD_FROM_SEL_OBJ(cb->cpnd_sync_sel), 30000);

	/* Destroy the sync - object */
	m_NCS_LOCK(&cb->cpnd_sync_lock, NCS_LOCK_WRITE);

	cb->cpnd_sync_awaited = false;
	m_NCS_SEL_OBJ_DESTROY(&cb->cpnd_sync_sel);

	m_NCS_UNLOCK(&cb->cpnd_sync_lock, NCS_LOCK_WRITE);
	return;
}
예제 #6
0
/****************************************************************************
 * Function Name: ncs_tmr_remaining
 *
 * Purpose:   This function calculates how much time is remaining for a
 *            particular timer.
 *
 ****************************************************************************/
uint32_t ncs_tmr_remaining(tmr_t tmrID, uint32_t *p_tleft)
{
	SYSF_TMR *tmr;
	uint32_t total_ticks_left;
	uint32_t ticks_elapsed;
	uint32_t ticks_to_expiry;

	if (((tmr = (SYSF_TMR *)tmrID) == NULL) || (tmr_destroying == true) || (p_tleft == NULL))
		return NCSCC_RC_FAILURE;

	*p_tleft = 0;
	TMR_DBG_ASSERT_ISA(tmr->dbg);	/* confirm that its timer memory */

	if (ncslpg_take(&gl_tcb.persist) == false)	/* guarentee persistence */
		return NCSCC_RC_FAILURE;

	m_NCS_LOCK(&gl_tcb.safe.enter_lock, NCS_LOCK_WRITE);	/* critical region START */
	if (!TMR_TEST_STATE(tmr, TMR_STATE_START)) {
		m_NCS_UNLOCK(&gl_tcb.safe.enter_lock, NCS_LOCK_WRITE);	/* critical region START */
		return NCSCC_RC_FAILURE;
	}
	m_NCS_UNLOCK(&gl_tcb.safe.enter_lock, NCS_LOCK_WRITE);	/* critical region START */
	ticks_elapsed = get_time_elapsed_in_ticks(&ts_start);
	ticks_to_expiry = m_NCS_OS_NTOHLL_P(&tmr->key);
	total_ticks_left = (ticks_to_expiry - ticks_elapsed);

	*p_tleft = total_ticks_left * NCS_MILLISECONDS_PER_TICK;

	return ncslpg_give(&gl_tcb.persist, NCSCC_RC_SUCCESS);
}
예제 #7
0
/********************************************************************
 Name    :  mqa_sync_with_mqnd

 Description : This is for MQA to sync with MQND when it gets MDS callback
 
**********************************************************************/
static void mqa_sync_with_mqnd(MQA_CB *cb)
{
	TRACE_ENTER();

	m_NCS_LOCK(&cb->mqnd_sync_lock, NCS_LOCK_WRITE);

	if (cb->is_mqnd_up) {
		TRACE_1("MQND is already up with the MQA");
		m_NCS_UNLOCK(&cb->mqnd_sync_lock, NCS_LOCK_WRITE);
		return;
	}

	cb->mqnd_sync_awaited = true;
	m_NCS_SEL_OBJ_CREATE(&cb->mqnd_sync_sel);
	m_NCS_UNLOCK(&cb->mqnd_sync_lock, NCS_LOCK_WRITE);

	/* Await indication from MDS saying MQND is up */
	osaf_poll_one_fd(m_GET_FD_FROM_SEL_OBJ(cb->mqnd_sync_sel), 30000);

	/* Destroy the sync - object */
	m_NCS_LOCK(&cb->mqnd_sync_lock, NCS_LOCK_WRITE);

	cb->mqnd_sync_awaited = false;
	m_NCS_SEL_OBJ_DESTROY(cb->mqnd_sync_sel);

	m_NCS_UNLOCK(&cb->mqnd_sync_lock, NCS_LOCK_WRITE);
	TRACE_1("MQND synced up with the MQA");
	TRACE_LEAVE();
	return;
}
예제 #8
0
/****************************************************************************
  Name          : avnd_mon_req_add

  Description   : This routine adds a request (node) to the pid_mon list. If
                  the record is already present, it is modified with the new
                  parameters.

  Arguments     : cb        - ptr to the AvND control block
                  pm_rec    - pointer to component PM_REC

  Return Values : ptr to the newly added/modified record

  Notes         : This will be called from the pm_rec_add function only.
******************************************************************************/
AVND_MON_REQ *avnd_mon_req_add(AVND_CB *cb, AVND_COMP_PM_REC *pm_rec)
{
	NCS_DB_LINK_LIST *pid_mon_list = &cb->pid_mon_list;
	AVND_MON_REQ *mon_req;
	uns32 rc = NCSCC_RC_SUCCESS;

	m_NCS_LOCK(&cb->mon_lock, NCS_LOCK_WRITE);

	/* get the record, if any */
	mon_req = (AVND_MON_REQ *) ncs_db_link_list_find(pid_mon_list, (uns8 *)&pm_rec->pid);
	if (!mon_req) {
		/* a new record.. alloc & link it to the dll */
		mon_req = (AVND_MON_REQ *) malloc(sizeof(AVND_MON_REQ));
		if (mon_req) {
			memset(mon_req, 0, sizeof(AVND_MON_REQ));

			mon_req->pid = pm_rec->pid;

			/* update the record key */
			mon_req->mon_dll_node.key = (uns8 *)&mon_req->pid;

			rc = ncs_db_link_list_add(pid_mon_list, &mon_req->mon_dll_node);
			if (NCSCC_RC_SUCCESS != rc) {
				m_NCS_UNLOCK(&cb->mon_lock, NCS_LOCK_WRITE);
				goto done;
			}
		} else {
			m_NCS_UNLOCK(&cb->mon_lock, NCS_LOCK_WRITE);
			LOG_ER("Memory Alloc Failed for MON_REQ structure");
			rc = NCSCC_RC_FAILURE;
			goto done;
		}
	}

	/* update the params */
	mon_req->pm_rec = pm_rec;

	m_NCS_UNLOCK(&cb->mon_lock, NCS_LOCK_WRITE);

	TRACE_1("PID: %lld added for (passive) Monitoring", mon_req->pid);

	/* PID monitoring task not yet created, so create */
	if (gl_avnd_mon_task_hdl == 0) {
		rc = avnd_mon_task_create();
	}

 done:
	if (NCSCC_RC_SUCCESS != rc) {
		if (mon_req) {
			avnd_mon_req_free(&mon_req->mon_dll_node);
			mon_req = 0;
		}
	}

	return mon_req;
}
예제 #9
0
/*************************************************************************** 
@brief		: saSmfDispatch 
@param[in]	: smfHandle - Handle returned by successful intialize. 
@param[in]	: dispatchFlags - Dispatch flag. 
@return		: SA_AIS_OK if successful otherwise appropiate err code.
*****************************************************************************/
SaAisErrorT saSmfDispatch(
		SaSmfHandleT smfHandle,
		SaDispatchFlagsT dispatchFlags)
{	
	
	SMFA_CB *cb = &_smfa_cb;
	SMFA_CLIENT_INFO *client_info;
	SaAisErrorT rc = SA_AIS_OK;

	TRACE_ENTER2("SMFA: Handle %llu.",smfHandle);
	if (cb->is_finalized){
		LOG_ER("SMFA: Already finalized, Bad handle: %llu.",smfHandle);
		TRACE_LEAVE();
		return SA_AIS_ERR_BAD_HANDLE;
	}
	
	/* To protect the finalize during dispatch.*/
	if (NCSCC_RC_SUCCESS != m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_READ)){
		LOG_ER("SMFA: Cb lock acquire FAILED.");
		TRACE_LEAVE();
		return SA_AIS_ERR_NO_RESOURCES;
	}
	
	/* Get the client info structure for the handle.*/
	client_info = smfa_client_info_get(smfHandle);
	if (NULL == client_info){
		LOG_ER("SMFA: Bad handle.");
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_READ);
		TRACE_LEAVE();
		return SA_AIS_ERR_BAD_HANDLE;
	}
	m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_READ);

	/* Validate the flags and invoke corresponding functions.*/
	switch(dispatchFlags){
		case SA_DISPATCH_ONE:
			rc = smfa_dispatch_cbk_one(client_info);
			break;
		case SA_DISPATCH_ALL:
			rc = smfa_dispatch_cbk_all(client_info);
			break;
		case SA_DISPATCH_BLOCKING:
			rc = smfa_dispatch_cbk_block(client_info);
			break;
		default:
			LOG_ER("SMFA: Invalid flag: %d",dispatchFlags);
			rc = SA_AIS_ERR_INVALID_PARAM;
	}
	TRACE_LEAVE();
	return rc;
}
예제 #10
0
/*************************************************************************** 
@brief		: saSmfFinalize 
@param[in]	: smfHandle - Handle returned by successful intialize. 
@return		: SA_AIS_OK if successful otherwise appropiate err code.
*****************************************************************************/
SaAisErrorT saSmfFinalize(SaSmfHandleT smfHandle)
{
	SMFA_CB *cb = &_smfa_cb;
	SMFA_CLIENT_INFO *client_info;
	
	TRACE_ENTER2("Handle: %llu",smfHandle);
	if (cb->is_finalized){
		LOG_ER("SMFA: Already finalized. Bad handle %llu.",smfHandle);
		TRACE_LEAVE();
		return SA_AIS_ERR_BAD_HANDLE;
	}

	if (NCSCC_RC_SUCCESS != m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_WRITE)){
		LOG_ER("SMFA: Cb lock acquire FAILED.");
		TRACE_LEAVE();
		return SA_AIS_ERR_NO_RESOURCES;
	}
	
	/* Get the client info structure for the handle.*/
	client_info = smfa_client_info_get(smfHandle);
	if (NULL == client_info){
		LOG_ER("SMFA: Could not retrieve client info, Bad handle %llu.",smfHandle);
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
		TRACE_LEAVE();
		return SA_AIS_ERR_BAD_HANDLE;
	}
	/* Free all the scope info registered for this client.*/
	smfa_client_info_clean(client_info);
	
	/* Release the MBX.*/
	m_NCS_IPC_DETACH(&client_info->cbk_mbx,smfa_client_mbx_clnup,client_info);
	m_NCS_IPC_RELEASE(&client_info->cbk_mbx,NULL);

	/* Clear the list cb->cbk_list for this handle.*/
	smfa_cbk_list_cleanup(smfHandle);

	/* Remove the client from the cb.*/
	smfa_client_info_rmv(client_info->client_hdl);
	
	m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
	
	/* If last client, then destroy the agent CB.*/
	if (NCSCC_RC_SUCCESS != smfa_finalize()){
		TRACE_LEAVE();
		return SA_AIS_ERR_LIBRARY;
	}

	TRACE_LEAVE();
	return SA_AIS_OK;
}
예제 #11
0
/*****************************************************************************

   PROCEDURE NAME:   ncshm_give_hdl

   DESCRIPTION:      Inform Hdl Manager that you are done with associated 
                     data.

*****************************************************************************/
void ncshm_give_hdl(uint32_t uhdl)
{
	HM_CELL *cell = NULL;
	HM_HDL *hdl = (HM_HDL *)&uhdl;
	uint32_t pool_id = 0;

	pool_id = m_HM_DETM_POOL_FRM_HDL(&uhdl);
	if (pool_id >= HM_POOL_CNT)
		return;

	m_NCS_LOCK(&gl_hm.lock[pool_id], NCS_LOCK_WRITE);

	if ((cell = hm_find_cell(hdl)) != NULL) {
		if (cell->seq_id == hdl->seq_id) {
			if (--cell->use_ct < 1) {
				m_LEAP_DBG_SINK(NCSCC_RC_FAILURE);	/* Client BUG..Too many give()s!! */
				cell->use_ct++;
			} else {
				if ((cell->busy == false) && (cell->use_ct == 1))
					hm_unblock_him(cell);
			}
		}
	}
	m_NCS_UNLOCK(&gl_hm.lock[pool_id], NCS_LOCK_WRITE);
}
예제 #12
0
NCSCONTEXT ncshm_destroy_hdl(NCS_SERVICE_ID id, uint32_t uhdl)
{
	HM_CELL *cell = NULL;
	HM_HDL *hdl = (HM_HDL *)&uhdl;
	NCSCONTEXT data = NULL;
	uint32_t pool_id = 0;

	pool_id = m_HM_DETM_POOL_FRM_HDL(&uhdl);
	if (pool_id >= HM_POOL_CNT)
		return NULL;

	m_NCS_LOCK(&gl_hm.lock[pool_id], NCS_LOCK_WRITE);

	if ((cell = hm_find_cell(hdl)) != NULL) {
		if ((cell->seq_id == hdl->seq_id) && ((NCS_SERVICE_ID)cell->svc_id == id) && (cell->busy == true)) {
			cell->busy = false;
			data = cell->data;

			if (cell->use_ct > 1) {
				hm_block_me(cell, (uint8_t)pool_id);	/* must unlock inside */
				m_NCS_LOCK(&gl_hm.lock[pool_id], NCS_LOCK_WRITE);	/* must lock again!!! */
			}
			hm_free_cell(cell, hdl, true);
		}
	}
	m_NCS_UNLOCK(&gl_hm.lock[pool_id], NCS_LOCK_WRITE);

	return data;
}
예제 #13
0
uint32_t ncshm_declare_hdl(uint32_t uhdl, NCS_SERVICE_ID id, NCSCONTEXT save)
{
	HM_FREE *free;
	HM_CELL *cell = NULL;
	HM_HDL *hdl = (HM_HDL *)&uhdl;
	uint32_t ret = NCSCC_RC_FAILURE;
	uint32_t pool_id = 0;

	pool_id = m_HM_DETM_POOL_FRM_HDL(&uhdl);
	if (pool_id >= HM_POOL_CNT)
		return ret;

	m_NCS_LOCK(&gl_hm.lock[pool_id], NCS_LOCK_WRITE);

	if ((free = hm_target_cell(hdl)) != NULL) {	/* must have THIS cell */
		cell = hm_find_cell(hdl);	/* These two lines are sanity */
		assert(((void *)free == (void *)cell));	/* checks that add no value   */

		cell->data = save;	/* store user stuff and internal state */
		cell->use_ct = 1;
		cell->svc_id = id;
		cell->busy = true;
		ret = NCSCC_RC_SUCCESS;
	}

	m_NCS_UNLOCK(&gl_hm.lock[pool_id], NCS_LOCK_WRITE);
	return ret;
}
예제 #14
0
/*****************************************************************************

   PROCEDURE NAME:   ncshm_create_hdl

   DESCRIPTION:      Secure a handle and bind associated client save data with
                     it. Return the uint32_t handle that leads to saved data.

*****************************************************************************/
uint32_t ncshm_create_hdl(uint8_t pool, NCS_SERVICE_ID id, NCSCONTEXT save)
{
	HM_FREE *free;
	HM_CELL *cell;
	uint32_t ret = 0;

	if (pool >= HM_POOL_CNT)
		return ret;	/* Invalid handle returned. */

	m_NCS_LOCK(&gl_hm.lock[pool], NCS_LOCK_WRITE);

	if ((free = hm_alloc_cell(pool)) != NULL) {
		cell = hm_find_cell(&free->hdl);	/* These two lines are sanity */
		assert(((void *)free == (void *)cell));	/* checks that add no value   */

		ret = (*(uint32_t *)&free->hdl);
		cell->data = save;	/* store user stuff and internal state */
		cell->use_ct = 1;
		cell->svc_id = id;
		cell->busy = true;
	}

	m_NCS_UNLOCK(&gl_hm.lock[pool], NCS_LOCK_WRITE);
	return ret;
}
예제 #15
0
/****************************************************************************
  Name          : mqa_mds_msg_sync_reply_direct
 
  Description   : This routine sends the MQA message to MQND.
 
  Arguments     : 
                  uns32 mqa_mds_hdl Handle of MQA
                  MDS_DEST  *destination - destintion to send to
                  MQSV_EVT   *i_evt - MQSV_EVT pointer
                  timeout - timeout value in 10 ms 
                 MDS_SYNC_SND_CTXT *context - context of MDS
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uns32 mqa_mds_msg_sync_reply_direct(uns32 mqa_mds_hdl,
				    MDS_DEST *destination,
				    MQSV_DSEND_EVT *i_evt, uns32 timeout, MDS_SYNC_SND_CTXT *context, uns32 length)
{
	NCSMDS_INFO mds_info;
	uns32 rc;
	MQA_CB *mqa_cb;

	if (!i_evt)
		return NCSCC_RC_FAILURE;

	/* retrieve MQA CB */
	mqa_cb = (MQA_CB *)m_MQSV_MQA_RETRIEVE_MQA_CB;

	if (!mqa_cb) {
		m_LOG_MQSV_A(MQA_CB_RETRIEVAL_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, NCSCC_RC_FAILURE, __FILE__,
			     __LINE__);
		mds_free_direct_buff((MDS_DIRECT_BUFF)i_evt);
		return NCSCC_RC_FAILURE;
	}

	/* Before entering any mds send function, the caller locks the control block with LOCK_WRITE. 
	   Unlock the control block before MDS send and lock it after we receive the reply * from MDS.  */
	if (m_NCS_UNLOCK(&mqa_cb->cb_lock, NCS_LOCK_WRITE) != NCSCC_RC_SUCCESS) {
		m_MQSV_MQA_GIVEUP_MQA_CB;
		mds_free_direct_buff((MDS_DIRECT_BUFF)i_evt);
		return NCSCC_RC_FAILURE;
	}

	memset(&mds_info, 0, sizeof(NCSMDS_INFO));
	mds_info.i_mds_hdl = mqa_mds_hdl;
	mds_info.i_svc_id = NCSMDS_SVC_ID_MQA;
	mds_info.i_op = MDS_DIRECT_SEND;

	/* fill the send structure */
	mds_info.info.svc_direct_send.i_direct_buff = (NCSCONTEXT)i_evt;
	mds_info.info.svc_direct_send.i_direct_buff_len = length;

	mds_info.info.svc_direct_send.i_priority = MDS_SEND_PRIORITY_MEDIUM;
	mds_info.info.svc_direct_send.i_to_svc = NCSMDS_SVC_ID_MQA;
	mds_info.info.svc_direct_send.i_msg_fmt_ver = i_evt->msg_fmt_version;

	mds_info.info.svc_direct_send.i_sendtype = MDS_SENDTYPE_SNDRACK;

	/* fill the sendinfo  strcuture */
	mds_info.info.svc_direct_send.info.sndrack.i_msg_ctxt = *context;
	mds_info.info.svc_direct_send.info.sndrack.i_sender_dest = *destination;
	mds_info.info.svc_direct_send.info.sndrack.i_time_to_wait = timeout;	/* timeto wait in 10ms */

	/* send the message. If MDS returns successfully, we assume that
	 * the reply message has been successfully delivered to the sender.  */
	rc = ncsmds_api(&mds_info);

	if (rc != NCSCC_RC_SUCCESS)
		m_LOG_MQSV_A(MQA_MDS_SEND_FAILURE, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__);

	m_NCS_LOCK(&mqa_cb->cb_lock, NCS_LOCK_WRITE);
	m_MQSV_MQA_GIVEUP_MQA_CB;
	return rc;
}
예제 #16
0
/**************************************************************************\
 *
 * add_new_req_pid_in_list
 *
 * Description: Add new request in the list..
 *
 * Synopsis:
 *
 * Call Arguments:
 *   pid - Process ID for which timeout has occurrend.
 *
 * Returns:
 *   None.
 *
 * Notes:
 *
\**************************************************************************/
uns32 add_new_req_pid_in_list(NCS_OS_PROC_EXECUTE_TIMED_INFO *req, uns32 pid)
{
	SYSF_PID_LIST *list_entry;

	if (module_cb.init == FALSE)
		return m_LEAP_DBG_SINK(NCSCC_RC_SUCCESS);

	if (NULL == (list_entry = m_MMGR_ALLOC_PRO_EXC))
		return m_LEAP_DBG_SINK(NCSCC_RC_FAILURE);

	list_entry->timeout_in_ms = req->i_timeout_in_ms;
	list_entry->exec_cb = req->i_cb;
	list_entry->usr_hdl = req->i_usr_hdl;
	list_entry->exec_hdl = req->o_exec_hdl = NCS_PTR_TO_UNS64_CAST(list_entry);
	list_entry->pid = pid;
	list_entry->pat_node.key_info = (uns8 *)&list_entry->pid;
	list_entry->exec_info_type = SYSF_EXEC_INFO_SIG_CHLD;

	m_NCS_LOCK(&module_cb.tree_lock, NCS_LOCK_WRITE);

	if (NCSCC_RC_SUCCESS != ncs_patricia_tree_add(&module_cb.pid_list, (NCS_PATRICIA_NODE *)list_entry)) {
		m_MMGR_FREE_PRO_EXC(list_entry);
		return m_LEAP_DBG_SINK(NCSCC_RC_FAILURE);
	}

	ncs_exc_mdl_start_timer(list_entry);

	m_NCS_UNLOCK(&module_cb.tree_lock, NCS_LOCK_WRITE);

	return NCSCC_RC_SUCCESS;
}
예제 #17
0
/****************************************************************************
  Name          : avnd_mon_req_del

  Description   : This routine deletes (unlinks & frees) the specified record
                  (node) from the pid_mon list.

  Arguments     : cb  - ptr to the AvND control block
                  pid - PID of the req node that is to be deleted

  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE

  Notes         : None.
******************************************************************************/
uns32 avnd_mon_req_del(AVND_CB *cb, SaUint64T pid)
{
	NCS_DB_LINK_LIST *pid_mon_list = &cb->pid_mon_list;
	uns32 rc;
	AVND_MON_REQ *mon_rec;

	m_NCS_LOCK(&cb->mon_lock, NCS_LOCK_WRITE);

	rc = ncs_db_link_list_del(pid_mon_list, (uns8 *)&pid);

	TRACE_1("PID: %lld deleted from (passive) Monitoring", pid);

	mon_rec = (AVND_MON_REQ *) m_NCS_DBLIST_FIND_FIRST(pid_mon_list);

	/* No more PIDs exists in the pid_mon_list for monitoring */
	if (!mon_rec) {
		/* destroy the task */
		if (gl_avnd_mon_task_hdl) {
			/* release the task */
			m_NCS_TASK_RELEASE(gl_avnd_mon_task_hdl);
			gl_avnd_mon_task_hdl = 0;

			TRACE_1("Passive Monitoring thread was released");
		}
	}

	m_NCS_UNLOCK(&cb->mon_lock, NCS_LOCK_WRITE);

	return rc;
}
예제 #18
0
/*****************************************************************************

   PROCEDURE NAME:   ncshm_take_hdl

   DESCRIPTION:      If all validation stuff is in order return the associated
                     data that this hdl leads to.

*****************************************************************************/
NCSCONTEXT ncshm_take_hdl(NCS_SERVICE_ID id, uint32_t uhdl)
{
	HM_CELL *cell = NULL;
	HM_HDL *hdl = (HM_HDL *)&uhdl;
	NCSCONTEXT data = NULL;
	uint32_t pool_id = 0;

	pool_id = m_HM_DETM_POOL_FRM_HDL(&uhdl);
	if (pool_id >= HM_POOL_CNT)
		return NULL;

	m_NCS_LOCK(&gl_hm.lock[pool_id], NCS_LOCK_WRITE);

	if ((cell = hm_find_cell(hdl)) != NULL) {
		if ((cell->seq_id == hdl->seq_id) && ((NCS_SERVICE_ID)cell->svc_id == id) && (cell->busy == true)) {
			if (++cell->use_ct == 0) {
				m_LEAP_DBG_SINK(NCSCC_RC_FAILURE);	/* Too many takes()s!! */
			}

			data = cell->data;
		}
	}

	m_NCS_UNLOCK(&gl_hm.lock[pool_id], NCS_LOCK_WRITE);
	return data;
}
예제 #19
0
SaUint32T plms_quiesced_state_handler(SaInvocationT invocation)
{

	PLMS_CB * cb = plms_cb;
	V_DEST_RL mds_role;

	/* Unregister with IMM as OI */
	plms_proc_active_quiesced_role_change();
	mds_role = V_DEST_RL_QUIESCED;
	TRACE_ENTER();
	m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_WRITE);

	/** set the CB's anchor value & mds role */

	cb->mds_role = mds_role;
	plms_mds_change_role();
	cb->amf_invocation_id = invocation;

	cb->is_quisced_set = true;
	LOG_IN("I AM IN HA AMF QUIESCED STATE\n");

	m_NCS_UNLOCK(&cb->cb_lock,NCS_LOCK_WRITE);

	TRACE_LEAVE();

	return NCSCC_RC_SUCCESS;

}
예제 #20
0
/****************************************************************************
 * Function Name: ncs_tmr_free
 *
 * Purpose: Mark this timer as DESTOYED.
 *
 ****************************************************************************/
void ncs_tmr_free(tmr_t tmrID)
{
	SYSF_TMR *tmr;

	if (((tmr = (SYSF_TMR *)tmrID) == NULL) || (tmr_destroying == true))
		return;

	TMR_DBG_ASSERT_ISA(tmr->dbg);	/* confirm that its timer memory */

	m_NCS_LOCK(&gl_tcb.safe.enter_lock, NCS_LOCK_WRITE);	/* critical region START */

#if ENABLE_SYSLOG_TMR_STATS
	if ((TMR_TEST_STATE(tmr, TMR_STATE_START))) {
		gl_tcb.stats.cnt--;
		if (gl_tcb.stats.cnt == 0) {
			syslog(LOG_INFO, "NO Timers Active Destroy PID %s \n", __LINE__);
		}
	}
#endif
	TMR_SET_STATE(tmr, TMR_STATE_DESTROY);

	/* here we can only selectively 0xff out memory fields */
	tmr->tmrCB = (TMR_CALLBACK)0x0ffffff;
	tmr->tmrUarg = (void *)0x0ffffff;
	m_NCS_UNLOCK(&gl_tcb.safe.enter_lock, NCS_LOCK_WRITE);	/* critical region END */
}
예제 #21
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);
}
예제 #22
0
/****************************************************************************
  Name          : immnd_mds_msg_send
 
  Description   : This routine sends the Events from IMMND
 
  Arguments     : cb  - ptr to the IMMND CB
                  i_evt - ptr to the IMMSV message
                  o_evt - ptr to the IMMSV message returned
                  timeout - timeout value in 10 ms 
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uint32_t immnd_mds_msg_send(IMMND_CB *cb, uint32_t to_svc, MDS_DEST to_dest, IMMSV_EVT *evt)
{
	NCSMDS_INFO mds_info;
	uint32_t rc;

	if (!evt)
		return NCSCC_RC_FAILURE;

	m_NCS_LOCK(&cb->immnd_immd_up_lock, NCS_LOCK_WRITE);

	if ((to_svc == NCSMDS_SVC_ID_IMMD) && (cb->is_immd_up == false)) {
		/* IMMD is not UP */
		TRACE_2("Director Service Is Down");
		m_NCS_UNLOCK(&cb->immnd_immd_up_lock, NCS_LOCK_WRITE);
		return NCSCC_RC_FAILURE;
	}

	m_NCS_UNLOCK(&cb->immnd_immd_up_lock, NCS_LOCK_WRITE);

	memset(&mds_info, 0, sizeof(NCSMDS_INFO));
	mds_info.i_mds_hdl = cb->immnd_mds_hdl;
	mds_info.i_svc_id = NCSMDS_SVC_ID_IMMND;
	mds_info.i_op = MDS_SEND;

	/* fill the send structure */
	mds_info.info.svc_send.i_msg = (NCSCONTEXT)evt;
	mds_info.info.svc_send.i_priority = MDS_SEND_PRIORITY_MEDIUM;
	mds_info.info.svc_send.i_to_svc = to_svc;
	mds_info.info.svc_send.i_sendtype = MDS_SENDTYPE_SND;
	mds_info.info.svc_send.info.snd.i_to_dest = to_dest;

	immsv_msg_trace_send(to_dest, evt);

	/* send the message */
	rc = ncsmds_api(&mds_info);

	if (rc != NCSCC_RC_SUCCESS) {
		LOG_WA("MDS Send Failed to service:%s rc:%u",
		       (to_svc == NCSMDS_SVC_ID_IMMD) ? "IMMD" :
		       (to_svc == NCSMDS_SVC_ID_IMMA_OM) ? "IMMA OM" :
		       (to_svc == NCSMDS_SVC_ID_IMMA_OI) ? "IMMA OI" :
		       (to_svc == NCSMDS_SVC_ID_IMMND) ? "IMMND" : "NO SERVICE!", rc);
	}

	return rc;
}
예제 #23
0
/****************************************************************************
  Name          : ava_hdl_cbk_dispatch_one
 
  Description   : This routine dispatches one pending callback.
 
  Arguments     : cb      - ptr to the AvA control block
                  hdl_rec - ptr to the handle record
 
  Return Values : SA_AIS_OK/SA_AIS_ERR_<CODE>
 
  Notes         : None.
******************************************************************************/
uint32_t ava_hdl_cbk_dispatch_one(AVA_CB **cb, AVA_HDL_REC **hdl_rec)
{
	AVA_PEND_RESP *list_resp = &(*hdl_rec)->pend_resp;
	AVA_PEND_CBK_REC *rec = 0;
	uint32_t hdl = (*hdl_rec)->hdl;
	SaAmfCallbacksT reg_cbk;
	uint32_t rc = SA_AIS_OK;
	TRACE_ENTER();

	memset(&reg_cbk, 0, sizeof(SaAmfCallbacksT));
	memcpy(&reg_cbk, &(*hdl_rec)->reg_cbk, sizeof(SaAmfCallbacksT));

	/* pop the rec from the mailbox queue */
	rec = (AVA_PEND_CBK_REC *)m_NCS_IPC_NON_BLK_RECEIVE(&(*hdl_rec)->callbk_mbx, NULL);

	if (rec) {

		if (rec->cbk_info->type != AVSV_AMF_PG_TRACK) {
			/* push this record into pending response list */
			m_AVA_HDL_PEND_RESP_PUSH(list_resp, (AVA_PEND_RESP_REC *)rec);
			m_AVA_HDL_CBK_REC_IN_DISPATCH_SET(rec);
		}

		/* release the cb lock & return the hdls to the hdl-mngr */
		m_NCS_UNLOCK(&(*cb)->lock, NCS_LOCK_WRITE);
		ncshm_give_hdl(hdl);

		/* process the callback list record */
		ava_hdl_cbk_rec_prc(rec->cbk_info, &reg_cbk);

		m_NCS_LOCK(&(*cb)->lock, NCS_LOCK_WRITE);

		if (0 == (*hdl_rec = ncshm_take_hdl(NCS_SERVICE_ID_AVA, hdl))) {
			/* hdl is already finalized */
			ava_hdl_cbk_rec_del(rec);
			TRACE_LEAVE2("Handle is already finalized");
			return rc;
		}

		/* if we are done with this rec, free it */
		if ((rec->cbk_info->type != AVSV_AMF_PG_TRACK) && m_AVA_HDL_IS_CBK_RESP_DONE(rec)) {
			m_AVA_HDL_PEND_RESP_POP(list_resp, rec, rec->cbk_info->inv);
			ava_hdl_cbk_rec_del(rec);
		} else if (rec->cbk_info->type == AVSV_AMF_PG_TRACK) {
			/* PG Track cbk do not have any response */
			ava_hdl_cbk_rec_del(rec);
		} else {
			m_AVA_HDL_CBK_REC_IN_DISPATCH_RESET(rec);
		}

	}
	else
		TRACE_3("No record to process the dispatch()");

	TRACE_LEAVE();
	return rc;
}
예제 #24
0
/****************************************************************************
 
  Name          : eda_find_subsc_validity
  Description   : This routine finds out whether the callback 
                  is for valid subscriber or not .
 
  Arguments     : cb      - ptr to the EDA control block
                  cbk_msg - ptr to the callback msg 
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
static uns32 eda_find_subsc_validity(EDA_CB *cb, EDSV_MSG *cbk_msg)
{
	EDA_CHANNEL_HDL_REC *chan_hdl_rec = NULL;
	EDA_EVENT_HDL_REC *evt_hdl_rec = NULL;
	EDSV_EDA_EVT_DELIVER_CBK_PARAM *evt_dlv_param = &cbk_msg->info.cbk_info.param.evt_deliver_cbk;
	SaEvtEventHandleT eventHandle = evt_dlv_param->event_hdl;
   /** Lookup the hdl rec 
    **/
	/* retrieve event hdl record */
	if (NULL == (evt_hdl_rec = (EDA_EVENT_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_EDA, eventHandle))) {
		m_LOG_EDSV_A(EDA_FAILURE, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, eventHandle, __FILE__, __LINE__, 0);
		return NCSCC_RC_FAILURE;
	}
	if (evt_hdl_rec->parent_chan) {	/* Check if channel still exists */
		if (evt_hdl_rec->parent_chan->channel_hdl) {
			/* retrieve the eda channel hdl record */
			if (NULL !=
			    (chan_hdl_rec =
			     (EDA_CHANNEL_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_EDA,
								   evt_hdl_rec->parent_chan->channel_hdl))) {
				if (NULL != eda_find_subsc_by_subsc_id(chan_hdl_rec, evt_dlv_param->sub_id)) {
					ncshm_give_hdl(eventHandle);
					ncshm_give_hdl(chan_hdl_rec->channel_hdl);
					return NCSCC_RC_SUCCESS;
				} else {
					if (chan_hdl_rec->subsc_list) {
						ncshm_give_hdl(eventHandle);
						ncshm_give_hdl(chan_hdl_rec->channel_hdl);
						return NCSCC_RC_SUCCESS;
					} else {
		    /** Lock EDA_CB synchronize access with MDS thread.
                     **/
						m_NCS_LOCK(&cb->cb_lock, NCS_LOCK_WRITE);

		     /** Delete this evt record from the
                      ** list of events
                      **/
						if (NCSCC_RC_SUCCESS !=
						    eda_event_hdl_rec_del(&chan_hdl_rec->chan_event_anchor,
									  evt_hdl_rec)) {
							ncshm_give_hdl(eventHandle);
						}
						m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
						ncshm_give_hdl(chan_hdl_rec->channel_hdl);
						return NCSCC_RC_FAILURE;

					}

				}
			}
		}
	}

	ncshm_give_hdl(eventHandle);
	return NCSCC_RC_FAILURE;

}
예제 #25
0
/****************************************************************************
  Name          : mqa_mds_msg_sync_send
 
  Description   : This routine sends the MQA message to MQND.
 
  Arguments     :
                  NCSCONTEXT mqa_mds_hdl Handle of MQA
                  MDS_DEST  *destination - destintion to send to
                  MQSV_EVT   *i_evt - MQSV_EVT pointer
                  MQSV_EVT   **o_evt - MQSV_EVT pointer to result data
                  timeout - timeout value in 10 ms 
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uns32 mqa_mds_msg_sync_send(uns32 mqa_mds_hdl, MDS_DEST *destination, MQSV_EVT *i_evt, MQSV_EVT **o_evt, uns32 timeout)
{

	NCSMDS_INFO mds_info;
	uns32 rc;
	MQA_CB *mqa_cb;

	if (!i_evt)
		return NCSCC_RC_FAILURE;

	/* retrieve MQA CB */
	mqa_cb = (MQA_CB *)m_MQSV_MQA_RETRIEVE_MQA_CB;

	if (!mqa_cb) {
		m_LOG_MQSV_A(MQA_CB_RETRIEVAL_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__);
		return NCSCC_RC_FAILURE;
	}

	/* Before entering any mds send function, the API locks the control block.
	 * unlock the control block before send and lock it after we receive the reply
	 */

	/* get the client_info */
	if (m_NCS_UNLOCK(&mqa_cb->cb_lock, NCS_LOCK_WRITE) != NCSCC_RC_SUCCESS) {
		m_MQSV_MQA_GIVEUP_MQA_CB;
		return NCSCC_RC_FAILURE;
	}

	memset(&mds_info, 0, sizeof(NCSMDS_INFO));
	mds_info.i_mds_hdl = mqa_mds_hdl;
	mds_info.i_svc_id = NCSMDS_SVC_ID_MQA;
	mds_info.i_op = MDS_SEND;

	/* fill the send structure */
	mds_info.info.svc_send.i_msg = (NCSCONTEXT)i_evt;
	mds_info.info.svc_send.i_priority = MDS_SEND_PRIORITY_MEDIUM;
	mds_info.info.svc_send.i_to_svc = NCSMDS_SVC_ID_MQND;
	mds_info.info.svc_send.i_sendtype = MDS_SENDTYPE_SNDRSP;

	/* fill the send rsp strcuture */
	mds_info.info.svc_send.info.sndrsp.i_time_to_wait = timeout;	/* timeto wait in 10ms */
	mds_info.info.svc_send.info.sndrsp.i_to_dest = *destination;

	/* send the message */
	rc = ncsmds_api(&mds_info);
	m_NCS_LOCK(&mqa_cb->cb_lock, NCS_LOCK_WRITE);

	if (rc == NCSCC_RC_SUCCESS)
		*o_evt = mds_info.info.svc_send.info.sndrsp.o_rsp;
	else
		m_LOG_MQSV_A(MQA_MDS_SEND_FAILURE, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__);

	m_MQSV_MQA_GIVEUP_MQA_CB;
	return rc;

}
예제 #26
0
SaUint32T plms_invalid_state_handler(SaInvocationT invocation)
{
	PLMS_CB * cb = plms_cb;
	TRACE_ENTER();
	m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_READ);
	saAmfResponse(cb->amf_hdl, invocation, SA_AIS_ERR_BAD_OPERATION);
	m_NCS_UNLOCK(&cb->cb_lock,NCS_LOCK_READ);
	TRACE_LEAVE();
	return NCSCC_RC_FAILURE;
}
예제 #27
0
uns32 mqa_mds_msg_async_send_direct(uns32 mqa_mds_hdl,
				    MDS_DEST *destination,
				    MQSV_DSEND_EVT *i_evt, uns32 to_svc, MDS_SEND_PRIORITY_TYPE priority, uns32 length)
{
	NCSMDS_INFO mds_info;
	uns32 rc;
	MQA_CB *mqa_cb;

	if (!i_evt)
		return NCSCC_RC_FAILURE;

	/* retrieve MQA CB */
	mqa_cb = (MQA_CB *)m_MQSV_MQA_RETRIEVE_MQA_CB;

	if (!mqa_cb) {
		m_LOG_MQSV_A(MQA_CB_RETRIEVAL_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, NCSCC_RC_FAILURE, __FILE__,
			     __LINE__);
		mds_free_direct_buff((MDS_DIRECT_BUFF)i_evt);
		return NCSCC_RC_FAILURE;
	}

	/* Before entering any mds send function, the API locks the control block.
	 * unlock the control block before send and lock it after we receive the reply */
	if (m_NCS_UNLOCK(&mqa_cb->cb_lock, NCS_LOCK_WRITE) != NCSCC_RC_SUCCESS) {
		m_MQSV_MQA_GIVEUP_MQA_CB;
		mds_free_direct_buff((MDS_DIRECT_BUFF)i_evt);
		return NCSCC_RC_FAILURE;
	}

	memset(&mds_info, 0, sizeof(NCSMDS_INFO));
	mds_info.i_mds_hdl = mqa_mds_hdl;
	mds_info.i_svc_id = NCSMDS_SVC_ID_MQA;
	mds_info.i_op = MDS_DIRECT_SEND;

	/* fill the send structure */
	mds_info.info.svc_direct_send.i_direct_buff = (NCSCONTEXT)i_evt;
	mds_info.info.svc_direct_send.i_direct_buff_len = length;

	mds_info.info.svc_direct_send.i_priority = priority;
	mds_info.info.svc_direct_send.i_to_svc = to_svc;
	mds_info.info.svc_direct_send.i_msg_fmt_ver = i_evt->msg_fmt_version;
	mds_info.info.svc_direct_send.i_sendtype = MDS_SENDTYPE_SND;

	/* fill the sendinfo  strcuture */
	mds_info.info.svc_direct_send.info.snd.i_to_dest = *destination;

	/* send the message */
	rc = ncsmds_api(&mds_info);
	if (rc != NCSCC_RC_SUCCESS)
		m_LOG_MQSV_A(MQA_MDS_SEND_FAILURE, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__);

	m_NCS_LOCK(&mqa_cb->cb_lock, NCS_LOCK_WRITE);
	m_MQSV_MQA_GIVEUP_MQA_CB;
	return rc;
}
예제 #28
0
/**************************************************************************\
 *
 * give_exec_mod_cb
 *
 * Description: Task to handle the signals.
 *
 * Synopsis:
 *
 * Call Arguments:
 *   pid - Process ID for which timeout has occurrend.
 *
 * Returns:
 *   None.
 *
 * Notes:
 *
\**************************************************************************/
void give_exec_mod_cb(int pid, uns32 status, int type)
{
	NCS_OS_PROC_EXECUTE_TIMED_CB_INFO cb_info;
	SYSF_PID_LIST *exec_pid;

	m_NCS_LOCK(&module_cb.tree_lock, NCS_LOCK_WRITE);

	memset(&cb_info, '\0', sizeof(NCS_OS_PROC_EXECUTE_TIMED_CB_INFO));

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

		if (SYSF_EXEC_INFO_TIME_OUT == type) {
			cb_info.exec_stat.value = NCS_OS_PROC_EXIT_WAIT_TIMEOUT;
			/*printf("\n%d Process terminated, callback given\n",exec_pid->pid); */
			m_NCS_OS_PROCESS_TERMINATE(exec_pid->pid);
			exec_pid->exec_info_type = SYSF_EXEC_INFO_TIME_OUT;
			cb_info.exec_stat.info.exit_with_code.exit_code = WEXITSTATUS(status);
		} else {

			/* Initialize the exit-code value. May be overridden below */
			cb_info.exec_stat.info.exit_with_code.exit_code = WEXITSTATUS(status);

			/* First stop timer */
			exec_pid->exec_info_type = SYSF_EXEC_INFO_SIG_CHLD;
			ncs_exc_mdl_stop_timer(exec_pid);

			/* Earlier "status = status >>8" now replaced with WEXITSTATUS macro */
			if (WIFEXITED(status) && (WEXITSTATUS(status) == 128)) {
				cb_info.exec_stat.value = NCS_OS_PROC_EXEC_FAIL;
			} else if (WIFEXITED(status) && (WEXITSTATUS(status) == 0)) {
				cb_info.exec_stat.value = NCS_OS_PROC_EXIT_NORMAL;
			} else if (WIFSIGNALED(status)) {
				cb_info.exec_stat.value = NCS_OS_PROC_EXIT_ON_SIGNAL;
				cb_info.exec_stat.info.exit_on_signal.signal_num = WTERMSIG(status);
			} else {	/* Just consider it to tbe EXIT-WITH-CODE .... */

				cb_info.exec_stat.value = NCS_OS_PROC_EXIT_WITH_CODE;
			}
		}

		cb_info.i_usr_hdl = exec_pid->usr_hdl;
		cb_info.i_exec_hdl = exec_pid->exec_hdl;

		exec_pid->exec_cb(&cb_info);
		if (type != SYSF_EXEC_INFO_TIME_OUT) {

			/* Remove entry from pat tree */
			ncs_patricia_tree_del(&module_cb.pid_list, (NCS_PATRICIA_NODE *)exec_pid);

			m_MMGR_FREE_PRO_EXC(exec_pid);
		}
	}
	m_NCS_UNLOCK(&module_cb.tree_lock, NCS_LOCK_WRITE);
}
예제 #29
0
/****************************************************************************
 * Name          : plms_amf_health_chk_callback
 *
 * Description   : This is the callback function which will be called 
 *                 when the AMF framework needs to health check for the component.
 *
 * Arguments     : invocation     - This parameter designated a particular 
 *                                  invocation of this callback function. The
 *                                  invoke process return invocation when it 
 *                                  responds to the Avilability Management 
 *                                  FrameWork using the saAmfResponse() 
 *                                  function.
 *                 compName       - A pointer to the name of the component 
 *                                  whose readiness state the Availability 
 *                                  Management Framework is setting.
 *                 checkType      - The type of healthcheck to be executed. 
 *
 * Return Values : None
 *
 * Notes         : At present we are just support a simple liveness check.
 *****************************************************************************/
void plms_amf_health_chk_callback(SaInvocationT invocation, const SaNameT *compName, SaAmfHealthcheckKeyT *checkType)
{
	PLMS_CB *cb = plms_cb;
	SaAisErrorT error = SA_AIS_OK;
	TRACE_ENTER();
	m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_READ);
	saAmfResponse(cb->amf_hdl, invocation, error);
	m_NCS_UNLOCK(&cb->cb_lock,NCS_LOCK_READ);
	TRACE_LEAVE();
	return;
}
예제 #30
0
/*************************************************************************** 
@brief		: saSmfSelectionObjectGet. If this api is called twice, same
		  sel obj will be returned. 
@param[in]	: smfHandle - Handle returned by successful intialize. 
@param[out]	: selectionObject - Will have a valid sel obj in successful
		  return of the api.
@return		: SA_AIS_OK if successful otherwise appropiate err code.
*****************************************************************************/
SaAisErrorT saSmfSelectionObjectGet( SaSmfHandleT smfHandle,
				SaSelectionObjectT *selectionObject)
{
	SMFA_CB *cb = &_smfa_cb;
	SMFA_CLIENT_INFO *client_info;
	
	TRACE_ENTER2("SMFA: Handle: %llu.",smfHandle);
	if (NULL == selectionObject){
		LOG_ER("SMFA: selectionObject is NULL.");
		TRACE_LEAVE();
		return SA_AIS_ERR_INVALID_PARAM;
	}
	
	/* To check if finalize is already called.*/
	if (cb->is_finalized){
		LOG_ER("SMFA: Already finalized, Bad handle: %llu.",smfHandle);
		TRACE_LEAVE();
		return SA_AIS_ERR_BAD_HANDLE;
	}
	
	if (NCSCC_RC_SUCCESS != m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_READ)){
		LOG_ER("SMFA: Cb lock acquire FAILED.");
		TRACE_LEAVE();
		return SA_AIS_ERR_NO_RESOURCES;
	}
	/* Get the client info structure for the handle.*/ 
	client_info = smfa_client_info_get(smfHandle);
	if (NULL == client_info){
		LOG_ER("SMFA: Could not retrieve client info, Bad handle: %llu",smfHandle);
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_READ);
		TRACE_LEAVE();
		return SA_AIS_ERR_BAD_HANDLE;
	}
	
	*selectionObject = (SaSelectionObjectT)m_GET_FD_FROM_SEL_OBJ(
			m_NCS_IPC_GET_SEL_OBJ(&client_info->cbk_mbx));
	
	m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_READ);
	TRACE_LEAVE();
	return SA_AIS_OK;
}