Exemplo n.º 1
0
/****************************************************************************
  Name          : ntfa_reader_hdl_rec_del
 
  Description   : This routine deletes the a log stream handle record from
                  a list of log stream hdl records. 
 
  Arguments     : NTFA_reader_hdl_REC **list_head
                  NTFA_reader_hdl_REC *rm_node

 
  Return Values : None
 
  Notes         : 
******************************************************************************/
uns32 ntfa_reader_hdl_rec_del(ntfa_reader_hdl_rec_t **list_head, ntfa_reader_hdl_rec_t *rm_node)
{
	/* Find the channel hdl record in the list of records */
	ntfa_reader_hdl_rec_t *list_iter = *list_head;

	/* If the to be removed record is the first record */
	if (list_iter == rm_node) {
		*list_head = rm_node->next;
	/** remove the association with hdl-mngr 
         **/
		ncshm_give_hdl(rm_node->reader_hdl);
		ncshm_destroy_hdl(NCS_SERVICE_ID_NTFA, rm_node->reader_hdl);
		free(rm_node);
		return NCSCC_RC_SUCCESS;
	} else {		/* find the rec */

		while (NULL != list_iter) {
			if (list_iter->next == rm_node) {
				list_iter->next = rm_node->next;
		/** remove the association with hdl-mngr 
                 **/
				ncshm_give_hdl(rm_node->reader_hdl);
				ncshm_destroy_hdl(NCS_SERVICE_ID_NTFA, rm_node->reader_hdl);
				free(rm_node);
				return NCSCC_RC_SUCCESS;
			}
			/* move onto the next one */
			list_iter = list_iter->next;
		}
	}
    /** The node couldn't be deleted **/
	TRACE("The node couldn't be deleted");
	return NCSCC_RC_FAILURE;
}
Exemplo n.º 2
0
/****************************************************************************
  Name          : ntfa_hdl_rec_del
 
  Description   : This routine deletes the a client handle record from
                  a list of client hdl records. 
 
  Arguments     : NTFA_CLIENT_HDL_REC **list_head
                  NTFA_CLIENT_HDL_REC *rm_node
 
  Return Values : None
 
  Notes         : The selection object is destroyed after all the means to 
                  access the handle record (ie. hdl db tree or hdl mngr) is 
                  removed. This is to disallow the waiting thread to access 
                  the hdl rec while other thread executes saAmfFinalize on it.
******************************************************************************/
uns32 ntfa_hdl_rec_del(ntfa_client_hdl_rec_t **list_head, ntfa_client_hdl_rec_t *rm_node)
{
	uns32 rc = NCSCC_RC_FAILURE;
	ntfa_client_hdl_rec_t *list_iter = *list_head;

	TRACE_ENTER();
/* TODO: free all resources allocated by the client */

	/* If the to be removed record is the first record */
	if (list_iter == rm_node) {
		*list_head = rm_node->next;

	/** detach & release the IPC 
         **/
		m_NCS_IPC_DETACH(&rm_node->mbx, ntfa_clear_mbx, NULL);
		m_NCS_IPC_RELEASE(&rm_node->mbx, NULL);

		ncshm_give_hdl(rm_node->local_hdl);
		ncshm_destroy_hdl(NCS_SERVICE_ID_NTFA, rm_node->local_hdl);
	/** Free the channel records off this hdl 
         **/
		ntfa_notification_hdl_rec_list_del(&rm_node->notification_list);

	/** free the hdl rec 
         **/
		free(rm_node);
		rc = NCSCC_RC_SUCCESS;
		goto out;
	} else {		/* find the rec */

		while (NULL != list_iter) {
			if (list_iter->next == rm_node) {
				list_iter->next = rm_node->next;

		/** detach & release the IPC */
				m_NCS_IPC_DETACH(&rm_node->mbx, ntfa_clear_mbx, NULL);
				m_NCS_IPC_RELEASE(&rm_node->mbx, NULL);

				ncshm_give_hdl(rm_node->local_hdl);
				ncshm_destroy_hdl(NCS_SERVICE_ID_NTFA, rm_node->local_hdl);
		/** Free the channel records off this ntfa_hdl  */
				ntfa_notification_hdl_rec_list_del(&rm_node->notification_list);

		/** free the hdl rec */
				free(rm_node);

				rc = NCSCC_RC_SUCCESS;
				goto out;
			}
			/* move onto the next one */
			list_iter = list_iter->next;
		}
	}
	TRACE("failed");

 out:
	TRACE_LEAVE();
	return rc;
}
Exemplo n.º 3
0
/****************************************************************************
  Name          : eda_hdl_rec_del
 
  Description   : This routine deletes the a client handle record from
                  a list of client hdl records. 
 
  Arguments     : EDA_CLIENT_HDL_REC **list_head
                  EDA_CLIENT_HDL_REC *rm_node
 
  Return Values : None
 
  Notes         : The selection object is destroyed after all the means to 
                  access the handle record (ie. hdl db tree or hdl mngr) is 
                  removed. This is to disallow the waiting thread to access 
                  the hdl rec while other thread executes saAmfFinalize on it.
******************************************************************************/
uns32 eda_hdl_rec_del(EDA_CLIENT_HDL_REC **list_head, EDA_CLIENT_HDL_REC *rm_node)
{
	/* Find the client hdl record in the list of records */
	EDA_CLIENT_HDL_REC *list_iter = *list_head;

	/* If the to be removed record is the first record */
	if (list_iter == rm_node) {
		*list_head = rm_node->next;

      /** detach & release the IPC 
       **/
		m_NCS_IPC_DETACH(&rm_node->mbx, eda_clear_mbx, NULL);
		m_NCS_IPC_RELEASE(&rm_node->mbx, NULL);

		ncshm_give_hdl(rm_node->local_hdl);
		ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, rm_node->local_hdl);
      /** Free the channel records off this hdl 
       **/
		eda_channel_hdl_rec_list_del(&rm_node->chan_list);

      /** free the hdl rec 
       **/
		m_MMGR_FREE_EDA_CLIENT_HDL_REC(rm_node);

		return NCSCC_RC_SUCCESS;
	} else {		/* find the rec */

		while (NULL != list_iter) {
			if (list_iter->next == rm_node) {
				list_iter->next = rm_node->next;

	    /** detach & release the IPC 
             **/
				m_NCS_IPC_DETACH(&rm_node->mbx, eda_clear_mbx, NULL);
				m_NCS_IPC_RELEASE(&rm_node->mbx, NULL);

				ncshm_give_hdl(rm_node->local_hdl);
				ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, rm_node->local_hdl);
	    /** Free the channel records off this eda_hdl  
             **/
				eda_channel_hdl_rec_list_del(&rm_node->chan_list);

	    /** free the hdl rec 
             **/
				m_MMGR_FREE_EDA_CLIENT_HDL_REC(rm_node);

				return NCSCC_RC_SUCCESS;
			}
			/* move onto the next one */
			list_iter = list_iter->next;
		}
	}
	m_LOG_EDSV_A(EDA_FAILURE, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__, 0);

	return NCSCC_RC_FAILURE;
}
Exemplo n.º 4
0
/****************************************************************************
  Name          : eda_event_hdl_rec_del
 
  Description   : This routine deletes the a event handle record from
                  a list of event hdl records. 
 
  Arguments     : EDA_EVENT_HDL_REC **list_head
                  EDA_EVENT_HDL_REC *rm_node

 
  Return Values : None
 
  Notes         : 
******************************************************************************/
uns32 eda_event_hdl_rec_del(EDA_EVENT_HDL_REC **list_head, EDA_EVENT_HDL_REC *rm_node)
{
	/* Find the event hdl record in the list of records */
	EDA_EVENT_HDL_REC *list_iter = *list_head;

	/* If the to be removed record is the first record */
	if (list_iter == rm_node) {
		*list_head = rm_node->next;
      /** remove the association with hdl-mngr 
       **/
		ncshm_give_hdl(rm_node->event_hdl);
		ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, rm_node->event_hdl);
      /** free pattern_array if any **/
		edsv_free_evt_pattern_array(rm_node->pattern_array);
      /** free the event data if any **/
		if (rm_node->evt_data) {
			m_MMGR_FREE_EDSV_EVENT_DATA(rm_node->evt_data);
			rm_node->evt_data = NULL;
		}
      /** Free the event hdl record 
       **/
		m_MMGR_FREE_EDA_EVENT_HDL_REC(rm_node);
		return NCSCC_RC_SUCCESS;
	} else {		/* find the rec */

		while (NULL != list_iter) {
			if (list_iter->next == rm_node) {
				list_iter->next = rm_node->next;
	    /** remove the association with hdl-mngr 
             **/
				ncshm_give_hdl(rm_node->event_hdl);
				ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, rm_node->event_hdl);
	    /** free pattern_array if any **/
				edsv_free_evt_pattern_array(rm_node->pattern_array);
	    /** free the event data if any **/
				if (rm_node->evt_data) {
					m_MMGR_FREE_EDSV_EVENT_DATA(rm_node->evt_data);
					rm_node->evt_data = NULL;
				}
	    /** Free the event hdl record 
             **/
				m_MMGR_FREE_EDA_EVENT_HDL_REC(rm_node);
				return NCSCC_RC_SUCCESS;
			}

			/* move onto the next one */
			list_iter = list_iter->next;
		}
	}
   /** The node couldn't be deleted **/
	m_LOG_EDSV_A(EDA_FAILURE, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__, 0);
	return NCSCC_RC_FAILURE;
}
Exemplo n.º 5
0
/****************************************************************************
  Name          : eda_channel_hdl_rec_del
 
  Description   : This routine deletes the a channel handle record from
                  a list of channel hdl records. 
 
  Arguments     : EDA_CHANNEL_HDL_REC **list_head
                  EDA_CHANNEL_HDL_REC *rm_node

 
  Return Values : None
 
  Notes         : 
******************************************************************************/
uns32 eda_channel_hdl_rec_del(EDA_CHANNEL_HDL_REC **list_head, EDA_CHANNEL_HDL_REC *rm_node)
{
	/* Find the channel hdl record in the list of records */
	EDA_CHANNEL_HDL_REC *list_iter = *list_head;

	/* If the to be removed record is the first record */
	if (list_iter == rm_node) {
		*list_head = rm_node->next;
      /** remove the association with hdl-mngr 
       **/
		ncshm_give_hdl(rm_node->channel_hdl);
		ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, rm_node->channel_hdl);
      /** Free the event hdl records off this hdl 
       **/
		eda_event_hdl_rec_list_del(&rm_node->chan_event_anchor);
      /** clean up the subscription records for this channel
       **/
		eda_subsc_rec_list_del(&rm_node->subsc_list);
      /** Free the channel hdl record 
       **/
		m_MMGR_FREE_EDA_CHANNEL_HDL_REC(rm_node);
		return NCSCC_RC_SUCCESS;
	} else {		/* find the rec */

		while (NULL != list_iter) {
			if (list_iter->next == rm_node) {
				list_iter->next = rm_node->next;
	    /** remove the association with hdl-mngr 
             **/
				ncshm_give_hdl(rm_node->channel_hdl);
				ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, rm_node->channel_hdl);
	    /** Free the event hdl records off this hdl  
             **/
				eda_event_hdl_rec_list_del(&rm_node->chan_event_anchor);
	    /** clean up the subscription records for this channel
             **/
				eda_subsc_rec_list_del(&rm_node->subsc_list);
	    /** Free the channel hdl record 
             **/
				m_MMGR_FREE_EDA_CHANNEL_HDL_REC(rm_node);
				return NCSCC_RC_SUCCESS;
			}
			/* move onto the next one */
			list_iter = list_iter->next;
		}
	}

   /** The node couldn't be deleted 
    **/
	m_LOG_EDSV_A(EDA_FAILURE, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__, 0);
	return NCSCC_RC_FAILURE;
}
Exemplo n.º 6
0
/****************************************************************************
  Name          : cpd_cpnd_info_node_delete
  Description   : This routine deletes the cpnd_info node from tree
  Arguments     : CPD_CB *cb - CPD Control Block.
                : CPD_CPND_INFO_NODE *cpnd_info - CPND Info Node.
  Return Values : None
  Notes         : None
******************************************************************************/
uns32 cpd_cpnd_info_node_delete(CPD_CB *cb, CPD_CPND_INFO_NODE *cpnd_info_node)
{
    uns32 rc = NCSCC_RC_SUCCESS;
    CPD_CKPT_REF_INFO *cref_info = NULL, *next_ref;

    /* Remove the internal linked list, if exists, The while loop will be executed
       only in case of clean up */
    if (cpnd_info_node == NULL) {
        m_LOG_CPD_CL(CPD_CPND_INFO_NODE_DELETE_FAILED, CPD_FC_HDLN, NCSFL_SEV_ERROR, __FILE__, __LINE__);
        return NCSCC_RC_FAILURE;
    }
    cref_info = cpnd_info_node->ckpt_ref_list;
    while (cref_info) {
        next_ref = cref_info->next;
        m_MMGR_FREE_CPD_CKPT_REF_INFO(cref_info);
        cref_info = next_ref;
    }

    /* Remove the Node from the client tree */
    if (ncs_patricia_tree_del(&cb->cpnd_tree, &cpnd_info_node->patnode) != NCSCC_RC_SUCCESS) {
        m_LOG_CPD_CL(CPD_CPND_INFO_NODE_DELETE_FAILED, CPD_FC_HDLN, NCSFL_SEV_ERROR, __FILE__, __LINE__);
        rc = NCSCC_RC_FAILURE;
    }

    /* Free the Client Node */
    if (cpnd_info_node) {
        if (cpnd_info_node->cpnd_ret_timer.uarg)
            ncshm_destroy_hdl(NCS_SERVICE_ID_CPD, cpnd_info_node->cpnd_ret_timer.uarg);

        m_MMGR_FREE_CPD_CPND_INFO_NODE(cpnd_info_node);
    }

    return rc;

}
Exemplo n.º 7
0
/*****************************************************************************
  PROCEDURE NAME : glnd_resource_req_node_del

  DESCRIPTION    : deletes the Resource request node 

  ARGUMENTS      :glnd_cb      - ptr to the GLND control block
                  

  RETURNS        :The pointer to the resource req node info on success.
                  else returns NULL.

  NOTES         : Delete the returned pointer immediately.
*****************************************************************************/
void glnd_resource_req_node_del(GLND_CB *glnd_cb, uint32_t res_req_hdl)
{
	GLND_RESOURCE_REQ_LIST *res_req_info;
	res_req_info = (GLND_RESOURCE_REQ_LIST *)ncshm_take_hdl(NCS_SERVICE_ID_GLND, res_req_hdl);

	if (res_req_info != NULL) {
		/* delete it from the list and return the pointer */
		if (glnd_cb->res_req_list == res_req_info)
			glnd_cb->res_req_list = glnd_cb->res_req_list->next;
		if (res_req_info->prev)
			res_req_info->prev->next = res_req_info->next;
		if (res_req_info->next)
			res_req_info->next->prev = res_req_info->prev;

		glnd_stop_tmr(&res_req_info->timeout);

		ncshm_give_hdl(res_req_hdl);
		/* destroy the handle */
		ncshm_destroy_hdl(NCS_SERVICE_ID_GLND, res_req_info->res_req_hdl_id);

		/* free the memory */
		m_MMGR_FREE_GLND_RESOURCE_REQ_LIST(res_req_info);

	}
	return;
}
Exemplo n.º 8
0
/****************************************************************************
  Name          : ava_hdl_rec_del
 
  Description   : This routine deletes the handle record.
 
  Arguments     : cb      - ptr tot he AvA control block
                  hdl_db  - ptr to the hdl db
                  hdl_rec - ptr to the hdl record
 
  Return Values : None
 
  Notes         : The selection object is destroyed after all the means to 
                  access the handle record (ie. hdl db tree or hdl mngr) is 
                  removed. This is to disallow the waiting thread to access 
                  the hdl rec while other thread executes saAmfFinalize on it.
******************************************************************************/
void ava_hdl_rec_del(AVA_CB *cb, AVA_HDL_DB *hdl_db, AVA_HDL_REC **_hdl_rec)
{
	AVA_HDL_REC *hdl_rec = *_hdl_rec;
	uint32_t hdl = hdl_rec->hdl;
	TRACE_ENTER();

	/* pop the hdl rec */
	ncs_patricia_tree_del(&hdl_db->hdl_db_anchor, &hdl_rec->hdl_node);

	/* detach the mail box */
	m_NCS_IPC_DETACH(&hdl_rec->callbk_mbx, ava_hdl_cbk_ipc_mbx_del, hdl_rec);

	/* delete the mailbox */
	m_NCS_IPC_RELEASE(&hdl_rec->callbk_mbx, NULL);

	/* clean the pend resp list */
	ava_hdl_pend_resp_list_del(cb, &hdl_rec->pend_resp);

	/* remove the association with hdl-mngr */
	ncshm_destroy_hdl(NCS_SERVICE_ID_AVA, hdl_rec->hdl);

	/* free the hdl rec */
	free(hdl_rec);
	*_hdl_rec = NULL;

	/* update the no of records */
	hdl_db->num--;

	TRACE_LEAVE2("Handle = %x, successfully deleted from Handle DB, num handles = %d",hdl, hdl_db->num);
	return;
}
Exemplo n.º 9
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;
}
Exemplo n.º 10
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);
}
Exemplo n.º 11
0
/****************************************************************************
  Name          : ntfa_notification_hdl_rec_list_del
 
  Description   : This routine deletes a list of log stream records.
 
  Arguments     : pointer to the list of notifiction records anchor.
 
  Return Values : None
 
  Notes         : 
******************************************************************************/
static void ntfa_notification_hdl_rec_list_del(ntfa_notification_hdl_rec_t **plstr_hdl)
{
	ntfa_notification_hdl_rec_t *lstr_hdl;
	while ((lstr_hdl = *plstr_hdl) != NULL) {
		*plstr_hdl = lstr_hdl->next;
		ncshm_destroy_hdl(NCS_SERVICE_ID_NTFA, lstr_hdl->notification_hdl);
		free(lstr_hdl);
		lstr_hdl = NULL;
	}
}
Exemplo n.º 12
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;
}
Exemplo n.º 13
0
/****************************************************************************
  Name          : eda_hdl_list_del
 
  Description   : This routine deletes all handles for this library.
 
  Arguments     : cb  - ptr to the EDA control block
 
  Return Values : None
 
  Notes         : None
******************************************************************************/
void eda_hdl_list_del(EDA_CLIENT_HDL_REC **p_client_hdl)
{
	EDA_CLIENT_HDL_REC *client_hdl;
	while ((client_hdl = *p_client_hdl) != NULL) {
		*p_client_hdl = client_hdl->next;
		ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, client_hdl->local_hdl);
      /** clean up the channel records for this eda-client
       **/
		eda_channel_hdl_rec_list_del(&client_hdl->chan_list);
      /** remove the association with hdl-mngr 
       **/
		m_MMGR_FREE_EDA_CLIENT_HDL_REC(client_hdl);
		client_hdl = 0;
	}
}
Exemplo n.º 14
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;
}
Exemplo n.º 15
0
/****************************************************************************
  Name          : ntfa_hdl_list_del
 
  Description   : This routine deletes all handles for this library.
 
  Arguments     : cb  - ptr to the NTFA control block
 
  Return Values : None
 
  Notes         : None
******************************************************************************/
void ntfa_hdl_list_del(ntfa_client_hdl_rec_t **p_client_hdl)
{
	ntfa_client_hdl_rec_t *client_hdl;

	while ((client_hdl = *p_client_hdl) != NULL) {
		*p_client_hdl = client_hdl->next;
		ncshm_destroy_hdl(NCS_SERVICE_ID_NTFA, client_hdl->local_hdl);
	/** clean up the channel records for this ntfa-client
         **/
		ntfa_notification_hdl_rec_list_del(&client_hdl->notification_list);
	/** remove the association with hdl-mngr 
         **/
		free(client_hdl);
		client_hdl = 0;
	}
}
Exemplo n.º 16
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);
}
Exemplo n.º 17
0
/****************************************************************************
  Name          : eda_channel_hdl_rec_list_del
 
  Description   : This routine deletes a list of channel records.
 
  Arguments     : pointer to the list of channel records anchor.
 
  Return Values : None
 
  Notes         : 
******************************************************************************/
static void eda_channel_hdl_rec_list_del(EDA_CHANNEL_HDL_REC **pchan_hdl)
{
	EDA_CHANNEL_HDL_REC *chan_hdl;
	while ((chan_hdl = *pchan_hdl) != NULL) {
		*pchan_hdl = chan_hdl->next;
      /** clean up the event records for this channel 
       **/
		ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, chan_hdl->channel_hdl);
		eda_event_hdl_rec_list_del(&chan_hdl->chan_event_anchor);
      /** clean up the subscription records for this channel
       **/
		eda_subsc_rec_list_del(&chan_hdl->subsc_list);
      /** remove the association with hdl-mngr 
       **/
		m_MMGR_FREE_EDA_CHANNEL_HDL_REC(chan_hdl);
		chan_hdl = NULL;
	}
}
Exemplo n.º 18
0
/****************************************************************************
  Name          : avnd_diq_rec_del
 
  Description   : This routine deletes the record from the AvD msg list.
 
  Arguments     : cb  - ptr to the AvND control block
                  rec - ptr to the AvD msg record
 
  Return Values : None.
 
  Notes         : None.
******************************************************************************/
void avnd_diq_rec_del(AVND_CB *cb, AVND_DND_MSG_LIST *rec)
{
	TRACE_ENTER();
	/* remove the association with hdl-mngr */
	if (rec->opq_hdl)
		ncshm_destroy_hdl(NCS_SERVICE_ID_AVND, rec->opq_hdl);

	/* stop the AvD msg response timer */
	if (m_AVND_TMR_IS_ACTIVE(rec->resp_tmr))
		m_AVND_TMR_MSG_RESP_STOP(cb, *rec);

	/* free the avnd message contents */
	avnd_msg_content_free(cb, &rec->msg);

	/* free the record */
	free(rec);
	TRACE_LEAVE();
	return;
}
Exemplo n.º 19
0
/****************************************************************************
  Name          : eda_event_hdl_rec_list_del
 
  Description   : This routine deletes a list of event records.
 
  Arguments     : pointer to the list of event records anchor.
 
  Return Values : None
 
  Notes         : 
******************************************************************************/
static void eda_event_hdl_rec_list_del(EDA_EVENT_HDL_REC **pevent_hdl)
{
	EDA_EVENT_HDL_REC *event_hdl;
	while (NULL != (event_hdl = *pevent_hdl)) {
		*pevent_hdl = event_hdl->next;

		ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, event_hdl->event_hdl);
      /** free pattern_array if any **/
		edsv_free_evt_pattern_array(event_hdl->pattern_array);
      /** free the event data if any **/
		if (event_hdl->evt_data) {
			m_MMGR_FREE_EDSV_EVENT_DATA(event_hdl->evt_data);
			event_hdl->evt_data = NULL;
		}
      /** remove the association with hdl-mngr 
       **/
		m_MMGR_FREE_EDA_EVENT_HDL_REC(event_hdl);
		event_hdl = NULL;
	}

}
Exemplo n.º 20
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;
}
Exemplo n.º 21
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;
}
Exemplo n.º 22
0
/****************************************************************************
 * Name          : gld_se_lib_destroy
 *
 * Description   : Invoked to destroy the GLD
 *                 
 *
 * Arguments     : 
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE..
 *
 * Notes         : None.
 *****************************************************************************/
uns32 gld_se_lib_destroy(NCS_LIB_REQ_INFO *req_info)
{
	GLSV_GLD_CB *gld_cb;

	if ((gld_cb = (NCSCONTEXT)ncshm_take_hdl(NCS_SERVICE_ID_GLD, gl_gld_hdl))
	    == NULL) {
		m_LOG_GLD_HEADLINE(GLD_TAKE_HANDLE_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0);
		return (NCSCC_RC_FAILURE);
	} else {
		/* Disconnect from MDS */
		gld_mds_shut(gld_cb);

		saAmfComponentUnregister(gld_cb->amf_hdl, &gld_cb->comp_name, (SaNameT *)NULL);
		saAmfFinalize(gld_cb->amf_hdl);

		ncshm_give_hdl(gl_gld_hdl);
		ncshm_destroy_hdl(NCS_SERVICE_ID_GLD, gl_gld_hdl);
		m_NCS_IPC_DETACH(&gld_cb->mbx, gld_clear_mbx, gld_cb);

		gld_cb_destroy(gld_cb);
		m_MMGR_FREE_GLSV_GLD_CB(gld_cb);
	}
	return (NCSCC_RC_SUCCESS);
}
Exemplo n.º 23
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;
}
Exemplo n.º 24
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;
}
Exemplo n.º 25
0
/****************************************************************************
  Name          : eda_hdl_rec_add
 
  Description   : This routine adds the handle record to the eda cb.
 
  Arguments     : cb       - ptr tot he EDA control block
                  reg_cbks - ptr to the set of registered callbacks
                  reg_id   - obtained from EDS.
                  version  - version of the client.
 
  Return Values : ptr to the eda handle record
 
  Notes         : None
******************************************************************************/
EDA_CLIENT_HDL_REC *eda_hdl_rec_add(EDA_CB **eda_cb, const SaEvtCallbacksT *reg_cbks, uns32 reg_id, SaVersionT version)
{
	EDA_CLIENT_HDL_REC *rec = 0;

	/* allocate the hdl rec */
	if (NULL == (rec = m_MMGR_ALLOC_EDA_CLIENT_HDL_REC)) {
		m_LOG_EDSV_A(EDA_MEMALLOC_FAILED, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__, 0);
		goto error;
	}

	memset(rec, '\0', sizeof(EDA_CLIENT_HDL_REC));

	/* create the association with hdl-mngr */
	if (0 == (rec->local_hdl = ncshm_create_hdl((*eda_cb)->pool_id, NCS_SERVICE_ID_EDA, (NCSCONTEXT)rec))) {
		m_LOG_EDSV_A(EDA_FAILURE, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__, 0);
		goto error;
	}

	/* store the registered callbacks */
	if (reg_cbks)
		memcpy((void *)&rec->reg_cbk, (void *)reg_cbks, sizeof(SaEvtCallbacksT));

   /** Associate with the reg_id obtained from EDS
    **/
	rec->eds_reg_id = reg_id;
	rec->version.releaseCode = version.releaseCode;
	rec->version.majorVersion = version.majorVersion;
	rec->version.minorVersion = version.minorVersion;

   /** Initialize and attach the IPC/Priority queue
    **/
	if (m_NCS_IPC_CREATE(&rec->mbx) != NCSCC_RC_SUCCESS) {
		m_LOG_EDSV_A(EDA_FAILURE, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__, 0);
		goto error;
	}
	if (m_NCS_IPC_ATTACH(&rec->mbx) != NCSCC_RC_SUCCESS) {
		m_LOG_EDSV_A(EDA_FAILURE, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__, 0);
		goto error;
	}
   /** Add this to the Link List of 
    ** CLIENT_HDL_RECORDS for this EDA_CB 
    **/

	m_NCS_LOCK(&((*eda_cb)->cb_lock), NCS_LOCK_WRITE);
	/* add this to the start of the list */
	rec->next = (*eda_cb)->eda_init_rec_list;
	(*eda_cb)->eda_init_rec_list = rec;
	m_NCS_UNLOCK(&((*eda_cb)->cb_lock), NCS_LOCK_WRITE);

	return rec;

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

      /** detach and release the IPC 
       **/
		m_NCS_IPC_DETACH(&rec->mbx, eda_clear_mbx, NULL);
		m_NCS_IPC_RELEASE(&rec->mbx, NULL);

		m_MMGR_FREE_EDA_CLIENT_HDL_REC(rec);
	}
	return NULL;
}
Exemplo n.º 26
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;
}
Exemplo n.º 27
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;
}
Exemplo n.º 28
0
/*****************************************************************************

PROCEDURE NAME:       main

DESCRIPTION:          Main routine for FM

*****************************************************************************/
int main(int argc, char *argv[])
{
	NCS_SEL_OBJ mbx_sel_obj, pipe_sel_obj, highest_sel_obj;
	NCS_SEL_OBJ amf_sel_obj = {0, 0};
	NCS_SEL_OBJ_SET sel_obj_set;
	FM_EVT *fm_mbx_evt = NULL;

	daemonize(argc, argv);

	if (fm_agents_startup() != NCSCC_RC_SUCCESS) {
/* notify the NID */
		fm_nid_notify((uns32)NCSCC_RC_FAILURE);
		goto fm_agents_startup_failed;
	}

/* Allocate memory for FM_CB. */
	fm_cb = m_MMGR_ALLOC_FM_CB;
	if (NULL == fm_cb) {
/* notify the NID */
		syslog(LOG_ERR, "CB Allocation failed.");
		fm_nid_notify((uns32)NCSCC_RC_FAILURE);
		goto fm_agents_startup_failed;
	}

	memset(fm_cb, 0, sizeof(FM_CB));

/* Create CB handle */
	gl_fm_hdl = ncshm_create_hdl(NCS_HM_POOL_ID_COMMON, NCS_SERVICE_ID_GFM, (NCSCONTEXT)fm_cb);

/* Take CB handle */
	ncshm_take_hdl(NCS_SERVICE_ID_GFM, gl_fm_hdl);

	if (fm_get_args(fm_cb) != NCSCC_RC_SUCCESS) {
/* notify the NID */
		fm_nid_notify((uns32)NCSCC_RC_FAILURE);
		goto fm_get_args_failed;
	}

/* Create MBX. */
	if (m_NCS_IPC_CREATE(&fm_cb->mbx) != NCSCC_RC_SUCCESS) {
		syslog(LOG_ERR, "m_NCS_IPC_CREATE() failed.");
		fm_nid_notify((uns32)NCSCC_RC_FAILURE);
		goto fm_get_args_failed;
	}

/* Attach MBX */
	if (m_NCS_IPC_ATTACH(&fm_cb->mbx) != NCSCC_RC_SUCCESS) {
		syslog(LOG_ERR, "m_NCS_IPC_ATTACH() failed.");
		fm_nid_notify((uns32)NCSCC_RC_FAILURE);
		goto fm_mbx_attach_failure;
	}

/* MDS initialization */
	if (fm_mds_init(fm_cb) != NCSCC_RC_SUCCESS) {
		fm_nid_notify((uns32)NCSCC_RC_FAILURE);
		goto fm_mds_init_failed;
	}

/* RDA initialization */
	if (fm_rda_init(fm_cb) != NCSCC_RC_SUCCESS) {
		fm_nid_notify((uns32)NCSCC_RC_FAILURE);
		goto fm_rda_init_failed;
	}

/* Open FM pipe for receiving AMF up intimation */
	if (fm_amf_open(&fm_cb->fm_amf_cb) != NCSCC_RC_SUCCESS) {
		fm_nid_notify((uns32)NCSCC_RC_FAILURE);
		goto fm_hpl_lib_init_failed;
	}

/* Get mailbox selection object */
	mbx_sel_obj = m_NCS_IPC_GET_SEL_OBJ(&fm_cb->mbx);

/* Get pipe selection object */
	m_SET_FD_IN_SEL_OBJ(fm_cb->fm_amf_cb.pipe_fd, pipe_sel_obj);

/* Give CB hdl */
	ncshm_give_hdl(gl_fm_hdl);

/* notify the NID */
	fm_nid_notify(NCSCC_RC_SUCCESS);

/* clear selection object set */
	m_NCS_SEL_OBJ_ZERO(&sel_obj_set);

/* Set only one pipe eelection object in set */
	m_NCS_SEL_OBJ_SET(pipe_sel_obj, &sel_obj_set);

	highest_sel_obj = pipe_sel_obj;

/* Wait for pipe selection object */
	if (m_NCS_SEL_OBJ_SELECT(highest_sel_obj, &sel_obj_set, NULL, NULL, NULL) != -1) {
/* following if will be true only first time */
		if (m_NCS_SEL_OBJ_ISSET(pipe_sel_obj, &sel_obj_set)) {
/* Take handle */
			ncshm_take_hdl(NCS_SERVICE_ID_GFM, gl_fm_hdl);

/* Process the message received on pipe */
			if (fm_amf_pipe_process_msg(&fm_cb->fm_amf_cb) != NCSCC_RC_SUCCESS)
				goto done;

/* Get amf selection object */
			m_SET_FD_IN_SEL_OBJ(fm_cb->fm_amf_cb.amf_fd, amf_sel_obj);

/* Release handle */
			ncshm_give_hdl(gl_fm_hdl);
		}
	}

/* clear selection object set */
	m_NCS_SEL_OBJ_ZERO(&sel_obj_set);
	m_NCS_SEL_OBJ_SET(amf_sel_obj, &sel_obj_set);
	m_NCS_SEL_OBJ_SET(mbx_sel_obj, &sel_obj_set);
	highest_sel_obj = m_GET_HIGHER_SEL_OBJ(amf_sel_obj, mbx_sel_obj);

/* Wait infinitely on  */
	while ((m_NCS_SEL_OBJ_SELECT(highest_sel_obj, &sel_obj_set, NULL, NULL, NULL) != -1)) {
		if (m_NCS_SEL_OBJ_ISSET(mbx_sel_obj, &sel_obj_set)) {
/* Take handle */
			ncshm_take_hdl(NCS_SERVICE_ID_GFM, gl_fm_hdl);

			fm_mbx_evt = (FM_EVT *)m_NCS_IPC_NON_BLK_RECEIVE(&fm_cb->mbx, msg);
			if (fm_mbx_evt) {
				fm_mbx_msg_handler(fm_cb, fm_mbx_evt);
			}
/* Release handle */
			ncshm_give_hdl(gl_fm_hdl);
		}

		if (m_NCS_SEL_OBJ_ISSET(amf_sel_obj, &sel_obj_set)) {
/* Take handle */
			ncshm_take_hdl(NCS_SERVICE_ID_GFM, gl_fm_hdl);

/* Process the message received on amf selection object */
			fm_amf_process_msg(&fm_cb->fm_amf_cb);

/* Release handle */
			ncshm_give_hdl(gl_fm_hdl);
		}

		m_NCS_SEL_OBJ_SET(amf_sel_obj, &sel_obj_set);
		m_NCS_SEL_OBJ_SET(mbx_sel_obj, &sel_obj_set);
		highest_sel_obj = m_GET_HIGHER_SEL_OBJ(amf_sel_obj, mbx_sel_obj);
	}

	fm_amf_close(&fm_cb->fm_amf_cb);

 fm_hpl_lib_init_failed:

	fm_rda_finalize(fm_cb);

 fm_rda_init_failed:

	fm_mds_finalize(fm_cb);

 fm_mds_init_failed:

	m_NCS_IPC_DETACH(&fm_cb->mbx, NULL, NULL);

 fm_mbx_attach_failure:

	m_NCS_IPC_RELEASE(&fm_cb->mbx, NULL);

 fm_get_args_failed:

	ncshm_destroy_hdl(NCS_SERVICE_ID_GFM, gl_fm_hdl);
	gl_fm_hdl = 0;
	m_MMGR_FREE_FM_CB(fm_cb);

 fm_agents_startup_failed:

	fm_agents_shutdown();
 done:
	return 1;
}
Exemplo n.º 29
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;
}
Exemplo n.º 30
0
/****************************************************************************
  Name          : ntfa_hdl_rec_add
 
  Description   : This routine adds the handle record to the ntfa cb.
 
  Arguments     : cb       - ptr tot he NTFA control block
                  reg_cbks - ptr to the set of registered callbacks
                  client_id   - obtained from NTFS.
 
  Return Values : ptr to the ntfa handle record
 
  Notes         : None
******************************************************************************/
ntfa_client_hdl_rec_t *ntfa_hdl_rec_add(ntfa_cb_t *cb, const SaNtfCallbacksT *reg_cbks, uns32 client_id)
{
	ntfa_client_hdl_rec_t *rec = calloc(1, sizeof(ntfa_client_hdl_rec_t));

	if (rec == NULL) {
		TRACE("calloc failed");
		goto done;
	}

	/* create the association with hdl-mngr */
	if (0 == (rec->local_hdl = ncshm_create_hdl(NCS_HM_POOL_ID_COMMON, NCS_SERVICE_ID_NTFA, (NCSCONTEXT)rec))) {
		TRACE("ncshm_create_hdl failed");
		goto err_free;
	}

	/* store the registered callbacks */
	if (reg_cbks)
		memcpy((void *)&rec->reg_cbk, (void *)reg_cbks, sizeof(SaNtfCallbacksT));

    /** Associate with the client_id obtained from NTFS
     **/
	rec->ntfs_client_id = client_id;

    /** Initialize and attach the IPC/Priority queue
     **/

	if (m_NCS_IPC_CREATE(&rec->mbx) != NCSCC_RC_SUCCESS) {
		TRACE("m_NCS_IPC_CREATE failed");
		goto err_destroy_hdl;
	}

	if (m_NCS_IPC_ATTACH(&rec->mbx) != NCSCC_RC_SUCCESS) {
		TRACE("m_NCS_IPC_ATTACH failed");
		goto err_ipc_release;
	}

    /** Add this to the Link List of 
     ** CLIENT_HDL_RECORDS for this NTFA_CB 
     **/

	pthread_mutex_lock(&cb->cb_lock);
	/* add this to the start of the list */
	rec->next = cb->client_list;
	cb->client_list = rec;
	pthread_mutex_unlock(&cb->cb_lock);

	goto done;

 err_ipc_release:
	(void)m_NCS_IPC_RELEASE(&rec->mbx, NULL);

 err_destroy_hdl:
	ncshm_destroy_hdl(NCS_SERVICE_ID_NTFA, rec->local_hdl);

 err_free:
	free(rec);
	rec = NULL;

 done:
	return rec;
}