/**************************************************************************** Name : mqa_queue_tree_delete_node Description : This routine adds the deletes the queue from the queue tree Arguments : queue_info - pointer to the queue node. Return Values : NCSCC_RC_FAILURE/NCSCC_RC_SUCCESS Notes : None ******************************************************************************/ uint32_t mqa_queue_tree_delete_node(MQA_CB *mqa_cb, SaMsgQueueHandleT hdl_id) { MQA_QUEUE_INFO *queue_info = NULL; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); queue_info = (MQA_QUEUE_INFO *)ncs_patricia_tree_get(&mqa_cb->mqa_queue_tree, (uint8_t *)&hdl_id); if (!queue_info) { TRACE_2("FAILURE: Adding the queue in the queue tree is failed"); return NCSCC_RC_FAILURE; } /* delete from the tree */ if ((rc = ncs_patricia_tree_del(&mqa_cb->mqa_queue_tree, &queue_info->patnode)) != NCSCC_RC_SUCCESS) TRACE_2("Queue database Deregistration Failed"); if (queue_info->task_handle != 0) { /* m_NCS_TASK_STOP(queue_info->task_handle); m_NCS_TASK_RELEASE(queue_info->task_handle); */ } /* free the mem */ m_MMGR_FREE_MQA_QUEUE_INFO(queue_info); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : mqa_queue_tree_cleanup Description : This routine cleansup the MQA queue tree Arguments : destroy_info - ptr to the destroy info Return Values : None Notes : None ******************************************************************************/ static void mqa_queue_tree_cleanup(MQA_CB *mqa_cb) { MQA_QUEUE_INFO *queue_info; SaMsgQueueHandleT *temp_ptr = NULL; SaMsgQueueHandleT temp_hdl; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); /* scan the entire handle db & delete each record */ while ((queue_info = (MQA_QUEUE_INFO *) ncs_patricia_tree_getnext(&mqa_cb->mqa_queue_tree, (uint8_t *const)temp_ptr))) { temp_hdl = queue_info->queueHandle; temp_ptr = &temp_hdl; /* delete the client info */ if ((rc = ncs_patricia_tree_del(&mqa_cb->mqa_queue_tree, &queue_info->patnode)) != NCSCC_RC_SUCCESS) { TRACE_2("Queue database Deregistration Failed"); } else { /* free the mem */ m_MMGR_FREE_MQA_QUEUE_INFO(queue_info); } } TRACE_LEAVE(); return; }
/**************************************************************************** Name : mqa_queue_tree_cleanup Description : This routine cleansup the MQA queue tree Arguments : destroy_info - ptr to the destroy info Return Values : None Notes : None ******************************************************************************/ static void mqa_queue_tree_cleanup(MQA_CB *mqa_cb) { MQA_QUEUE_INFO *queue_info; SaMsgQueueHandleT *temp_ptr = NULL; SaMsgQueueHandleT temp_hdl; uns32 rc = NCSCC_RC_SUCCESS; /* scan the entire handle db & delete each record */ while ((queue_info = (MQA_QUEUE_INFO *) ncs_patricia_tree_getnext(&mqa_cb->mqa_queue_tree, (uns8 *const)temp_ptr))) { temp_hdl = queue_info->queueHandle; temp_ptr = &temp_hdl; /* delete the client info */ if ((rc = ncs_patricia_tree_del(&mqa_cb->mqa_queue_tree, &queue_info->patnode)) != NCSCC_RC_SUCCESS) { m_LOG_MQSV_A(MQA_QUEUE_TREE_DEL_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__); } else { /* free the mem */ m_MMGR_FREE_MQA_QUEUE_INFO(queue_info); } } return; }
/**************************************************************************** Name : mqa_queue_tree_find_and_add Description : This routine adds the new queue to the queue tree 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. MQA_CLIENT_INFO *client_info : Info about the client. SaMsgQueueOpenFlagsT openFlags : If flag == true, openFlags is IN parameter. If flag != true, openFlags is ignored. Return Values : returns the MQA_QUEUE_INFO node. Notes : None ******************************************************************************/ MQA_QUEUE_INFO *mqa_queue_tree_find_and_add(MQA_CB *mqa_cb, SaMsgQueueHandleT hdl_id, bool flag, MQA_CLIENT_INFO *client_info, SaMsgQueueOpenFlagsT openFlags) { MQA_QUEUE_INFO *queue_info = NULL; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); /* read lock taken by the caller. */ queue_info = (MQA_QUEUE_INFO *)ncs_patricia_tree_get(&mqa_cb->mqa_queue_tree, (uint8_t *)&hdl_id); if (flag == true) { /* create and allocate the memory */ if (!queue_info) { queue_info = (MQA_QUEUE_INFO *)m_MMGR_ALLOC_MQA_QUEUE_INFO; if (!queue_info) { TRACE_2("Queue database creation failed"); return NULL; } memset(queue_info, 0, sizeof(MQA_QUEUE_INFO)); queue_info->queueHandle = hdl_id; queue_info->openFlags = openFlags; queue_info->client_info = client_info; queue_info->patnode.key_info = (uint8_t *)&queue_info->queueHandle; queue_info->msg_get_count = 0; if ((rc = ncs_patricia_tree_add(&mqa_cb->mqa_queue_tree, &queue_info->patnode)) != NCSCC_RC_SUCCESS) { TRACE_2("Queue database Registration Failed"); m_MMGR_FREE_MQA_QUEUE_INFO(queue_info); return NULL; } } } TRACE_LEAVE(); return queue_info; }
/**************************************************************************** Name : mqa_queue_tree_find_and_add Description : This routine adds the new queue to the queue tree 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. MQA_CLIENT_INFO *client_info : Info about the client. SaMsgQueueOpenFlagsT openFlags : If flag == TRUE, openFlags is IN parameter. If flag != TRUE, openFlags is ignored. Return Values : returns the MQA_QUEUE_INFO node. Notes : None ******************************************************************************/ MQA_QUEUE_INFO *mqa_queue_tree_find_and_add(MQA_CB *mqa_cb, SaMsgQueueHandleT hdl_id, NCS_BOOL flag, MQA_CLIENT_INFO *client_info, SaMsgQueueOpenFlagsT openFlags) { MQA_QUEUE_INFO *queue_info = NULL; uns32 rc = NCSCC_RC_SUCCESS; /* read lock taken by the caller. */ queue_info = (MQA_QUEUE_INFO *)ncs_patricia_tree_get(&mqa_cb->mqa_queue_tree, (uns8 *)&hdl_id); if (flag == TRUE) { /* create and allocate the memory */ if (!queue_info) { queue_info = (MQA_QUEUE_INFO *)m_MMGR_ALLOC_MQA_QUEUE_INFO; if (!queue_info) { m_LOG_MQSV_A(MQA_QUEUE_ALLOC_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__); return NULL; } memset(queue_info, 0, sizeof(MQA_QUEUE_INFO)); queue_info->queueHandle = hdl_id; queue_info->openFlags = openFlags; queue_info->client_info = client_info; queue_info->patnode.key_info = (uns8 *)&queue_info->queueHandle; queue_info->msg_get_count = 0; if ((rc = ncs_patricia_tree_add(&mqa_cb->mqa_queue_tree, &queue_info->patnode)) != NCSCC_RC_SUCCESS) { m_LOG_MQSV_A(MQA_QUEUE_TREE_ADD_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__); m_MMGR_FREE_MQA_QUEUE_INFO(queue_info); return NULL; } } } return queue_info; }
/**************************************************************************** Name : mqa_queue_tree_delete_node Description : This routine adds the deletes the queue from the queue tree Arguments : queue_info - pointer to the queue node. Return Values : NCSCC_RC_FAILURE/NCSCC_RC_SUCCESS Notes : None ******************************************************************************/ uns32 mqa_queue_tree_delete_node(MQA_CB *mqa_cb, SaMsgQueueHandleT hdl_id) { MQA_QUEUE_INFO *queue_info = NULL; uns32 rc = NCSCC_RC_SUCCESS; queue_info = (MQA_QUEUE_INFO *)ncs_patricia_tree_get(&mqa_cb->mqa_queue_tree, (uns8 *)&hdl_id); if (!queue_info) { return NCSCC_RC_FAILURE; } /* delete from the tree */ if ((rc = ncs_patricia_tree_del(&mqa_cb->mqa_queue_tree, &queue_info->patnode)) != NCSCC_RC_SUCCESS) m_LOG_MQSV_A(MQA_QUEUE_TREE_DEL_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__); if (queue_info->task_handle != 0) { /* m_NCS_TASK_STOP(queue_info->task_handle); m_NCS_TASK_RELEASE(queue_info->task_handle); */ } /* free the mem */ m_MMGR_FREE_MQA_QUEUE_INFO(queue_info); return NCSCC_RC_SUCCESS; }