Beispiel #1
0
/****************************************************************************
  Name          : mqa_client_tree_find_and_add
 
  Description   : This routine adds the new client to the client tree and creates
                  the selection object for that client.
 
  Arguments     : 
                  mqa_cb : pointer to the mqa control block.
                  hdl_id : the handle id.
                  flag   : true/false if true create the new node if node 
                           doesn't exist.FALSE -> search for an existing node.
 
  Return Values : returns the MQA_CLIENT_INFO node.
 
  Notes         : The caller takes the cb lock before calling this function
                  
******************************************************************************/
MQA_CLIENT_INFO *mqa_client_tree_find_and_add(MQA_CB *mqa_cb, SaMsgHandleT hdl_id, bool flag)
{
	MQA_CLIENT_INFO *client_info = NULL;
	NCS_PATRICIA_PARAMS param;
	uint32_t rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();

	client_info = (MQA_CLIENT_INFO *)ncs_patricia_tree_get(&mqa_cb->mqa_client_tree, (uint8_t *)&hdl_id);

	if (flag == true) {
		/* create and allocate the memory */
		if (!client_info) {
			client_info = (MQA_CLIENT_INFO *)m_MMGR_ALLOC_MQA_CLIENT_INFO;
			if (!client_info) {
				TRACE_4("Client database creation failed");
				return NULL;
			}
			memset(client_info, 0, sizeof(MQA_CLIENT_INFO));
			/* Store the client_info pointer as msghandle. */
			client_info->msgHandle = NCS_PTR_TO_UNS64_CAST(client_info);
			client_info->patnode.key_info = (uint8_t *)&client_info->msgHandle;

			if ((rc =
			     ncs_patricia_tree_add(&mqa_cb->mqa_client_tree,
						   &client_info->patnode)) != NCSCC_RC_SUCCESS) {
				TRACE_2("Client database Registration Failed");
				m_MMGR_FREE_MQA_CLIENT_INFO(client_info);
				return NULL;
			}

			/* Create the group track tree */
			memset(&param, 0, sizeof(NCS_PATRICIA_PARAMS));
			param.key_size = SA_MAX_NAME_LENGTH;
			if (ncs_patricia_tree_init(&client_info->mqa_track_tree, &param) != NCSCC_RC_SUCCESS) {
				TRACE_2("Initialization of the client tree failed");
				m_MMGR_FREE_MQA_CLIENT_INFO(client_info);
				return NULL;
			}

		}
	}
	TRACE_LEAVE();
	return client_info;
}
Beispiel #2
0
/****************************************************************************
  Name          : mqa_client_tree_find_and_add
 
  Description   : This routine adds the new client to the client tree and creates
                  the selection object for that client.
 
  Arguments     : 
                  mqa_cb : pointer to the mqa control block.
                  hdl_id : the handle id.
                  flag   : TRUE/FALSE if TRUE create the new node if node 
                           doesn't exist.FALSE -> search for an existing node.
 
  Return Values : returns the MQA_CLIENT_INFO node.
 
  Notes         : The caller takes the cb lock before calling this function
                  
******************************************************************************/
MQA_CLIENT_INFO *mqa_client_tree_find_and_add(MQA_CB *mqa_cb, SaMsgHandleT hdl_id, NCS_BOOL flag)
{
	MQA_CLIENT_INFO *client_info = NULL;
	NCS_PATRICIA_PARAMS param;
	uns32 rc = NCSCC_RC_SUCCESS;

	client_info = (MQA_CLIENT_INFO *)ncs_patricia_tree_get(&mqa_cb->mqa_client_tree, (uns8 *)&hdl_id);

	if (flag == TRUE) {
		/* create and allocate the memory */
		if (!client_info) {
			client_info = (MQA_CLIENT_INFO *)m_MMGR_ALLOC_MQA_CLIENT_INFO;
			if (!client_info) {
				m_LOG_MQSV_A(MQA_CLIENT_ALLOC_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__,
					     __LINE__);
				return NULL;
			}
			memset(client_info, 0, sizeof(MQA_CLIENT_INFO));
			/* Store the client_info pointer as msghandle. */
			client_info->msgHandle = NCS_PTR_TO_UNS64_CAST(client_info);
			client_info->patnode.key_info = (uns8 *)&client_info->msgHandle;

			if ((rc =
			     ncs_patricia_tree_add(&mqa_cb->mqa_client_tree,
						   &client_info->patnode)) != NCSCC_RC_SUCCESS) {
				m_LOG_MQSV_A(MQA_CLIENT_TREE_ADD_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc,
					     __FILE__, __LINE__);
				m_MMGR_FREE_MQA_CLIENT_INFO(client_info);
				return NULL;
			}

			/* Create the group track tree */
			memset(&param, 0, sizeof(NCS_PATRICIA_PARAMS));
			param.key_size = SA_MAX_NAME_LENGTH;
			if (ncs_patricia_tree_init(&client_info->mqa_track_tree, &param) != NCSCC_RC_SUCCESS) {
				m_MMGR_FREE_MQA_CLIENT_INFO(client_info);
				return NULL;
			}

		}
	}
	return client_info;
}
Beispiel #3
0
/****************************************************************************
  Name          : mqa_client_tree_delete_node
 
  Description   : This routine adds the deletes the client from the client tree
 
  Arguments     : client_info - pointer to the client node.
                  
 
  Return Values : NCSCC_RC_FAILURE/NCSCC_RC_SUCCESS
 
  Notes         : None
******************************************************************************/
uint32_t mqa_client_tree_delete_node(MQA_CB *mqa_cb, MQA_CLIENT_INFO *client_info)
{
	MQA_TRACK_INFO *track_info;
	SaNameT *temp_ptr = 0;
	SaNameT temp_name;
	uint8_t *value = NULL;
	uint32_t rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();

	/* scan the entire group track db & delete each record */
	while ((track_info = (MQA_TRACK_INFO *)ncs_patricia_tree_getnext(&client_info->mqa_track_tree, value))) {
		/* delete the track info */
		temp_name = track_info->queueGroupName;
		temp_ptr = &temp_name;
		value = temp_ptr->value;
		/* delete from the tree */
		if ((rc = ncs_patricia_tree_del(&client_info->mqa_track_tree,
						&track_info->patnode)) != NCSCC_RC_SUCCESS)
			TRACE_2("Track Database Deregistration Failed");

		/* free the mem */
		if (track_info->notificationBuffer.notification)
			m_MMGR_FREE_MQA_TRACK_BUFFER_INFO(track_info->notificationBuffer.notification);
		m_MMGR_FREE_MQA_TRACK_INFO(track_info);
	}

	/* destroy the tree */
	ncs_patricia_tree_destroy(&client_info->mqa_track_tree);

	/* delete from the tree */
	if ((rc = ncs_patricia_tree_del(&mqa_cb->mqa_client_tree, &client_info->patnode)) != NCSCC_RC_SUCCESS)
		TRACE_2("Client database Deregistration Failed");

	/* free the mem */
	m_MMGR_FREE_MQA_CLIENT_INFO(client_info);
	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
Beispiel #4
0
/****************************************************************************
  Name          : mqa_client_tree_delete_node
 
  Description   : This routine adds the deletes the client from the client tree
 
  Arguments     : client_info - pointer to the client node.
                  
 
  Return Values : NCSCC_RC_FAILURE/NCSCC_RC_SUCCESS
 
  Notes         : None
******************************************************************************/
uns32 mqa_client_tree_delete_node(MQA_CB *mqa_cb, MQA_CLIENT_INFO *client_info)
{
	MQA_TRACK_INFO *track_info;
	SaNameT *temp_ptr = 0;
	SaNameT temp_name;
	uns8 *value = NULL;
	uns32 rc = NCSCC_RC_SUCCESS;
	/* scan the entire group track db & delete each record */
	while ((track_info = (MQA_TRACK_INFO *)ncs_patricia_tree_getnext(&client_info->mqa_track_tree, value))) {
		/* delete the track info */
		temp_name = track_info->queueGroupName;
		temp_ptr = &temp_name;
		value = temp_ptr->value;
		/* delete from the tree */
		if ((rc = ncs_patricia_tree_del(&client_info->mqa_track_tree,
						&track_info->patnode)) != NCSCC_RC_SUCCESS)
			m_LOG_MQSV_A(MQA_TRACK_TREE_DEL_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__,
				     __LINE__);

		/* free the mem */
		if (track_info->notificationBuffer.notification)
			m_MMGR_FREE_MQA_TRACK_BUFFER_INFO(track_info->notificationBuffer.notification);
		m_MMGR_FREE_MQA_TRACK_INFO(track_info);
	}

	/* destroy the tree */
	ncs_patricia_tree_destroy(&client_info->mqa_track_tree);

	/* delete from the tree */
	if ((rc = ncs_patricia_tree_del(&mqa_cb->mqa_client_tree, &client_info->patnode)) != NCSCC_RC_SUCCESS)
		m_LOG_MQSV_A(MQA_CLIENT_TREE_DEL_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__);

	/* free the mem */
	m_MMGR_FREE_MQA_CLIENT_INFO(client_info);
	return NCSCC_RC_SUCCESS;
}