Ejemplo n.º 1
0
/************************************************************************************
 * Name           :glsv_gld_mbcsv_dec_sync_resp 
 *
 * Description    : Decode the message at Standby for cold sync and update the database

 * Arguments      : NCS_MBCSV_CB_ARG - MBCSv callback argument
 *
 * Return Values  : Success / Error
*************************************************************************************/
static uint32_t glsv_gld_mbcsv_dec_sync_resp(GLSV_GLD_CB *gld_cb, NCS_MBCSV_CB_ARG *arg)
{
	uint8_t *ptr, num_of_ckpts, data[16];
	GLSV_GLD_A2S_RSC_DETAILS *rsc_info;
	uint32_t count = 0, rc = NCSCC_RC_SUCCESS, num_of_async_upd;
	EDU_ERR ederror = 0;
	GLSV_A2S_NODE_LIST *node_list, *tmp1_node_list;
	TRACE_ENTER();

	if (arg->info.decode.i_uba.ub == NULL) {	/* There is no data */
		goto end;
	}

	/* Allocate memory */
	rsc_info = m_MMGR_ALLOC_GLSV_GLD_A2S_RSC_DETAILS;
	if (rsc_info == NULL) {
		LOG_CR("Rsc info alloc failed: Error %s", strerror(errno));
		assert(0);
	}

	memset(rsc_info, 0, sizeof(GLSV_GLD_A2S_RSC_DETAILS));

	/* 1. Decode the 1st uint8_t region ,  we will get the num of ckpts */
	ptr = ncs_dec_flatten_space(&arg->info.decode.i_uba, data, sizeof(uint8_t));
	num_of_ckpts = ncs_decode_8bit(&ptr);
	ncs_dec_skip_space(&arg->info.decode.i_uba, sizeof(uint8_t));

	/* Decode the data */

	while (count < num_of_ckpts) {
		rc = m_NCS_EDU_EXEC(&gld_cb->edu_hdl, glsv_edp_gld_evt_a2s_rsc_details, &arg->info.decode.i_uba,
				    EDP_OP_TYPE_DEC, &rsc_info, &ederror);
		if (rc != NCSCC_RC_SUCCESS) {
			goto end;
		}
		rc = gld_sb_proc_data_rsp(gld_cb, rsc_info);
		count++;
		memset(rsc_info, 0, sizeof(GLSV_GLD_A2S_RSC_DETAILS));
	}

	/* Get the async update count */
	ptr = ncs_dec_flatten_space(&arg->info.decode.i_uba, data, sizeof(uint32_t));
	num_of_async_upd = ncs_decode_32bit(&ptr);
	gld_cb->gld_async_cnt = num_of_async_upd;

	/* New code */
	node_list = rsc_info->node_list;
	while (node_list != NULL) {
		tmp1_node_list = node_list;
		node_list = node_list->next;
		m_MMGR_FREE_GLSV_NODE_LIST(tmp1_node_list);
	}
	m_MMGR_FREE_GLSV_GLD_A2S_RSC_DETAILS(rsc_info);
 end:
	TRACE_LEAVE();
	return rc;
}
Ejemplo n.º 2
0
/****************************************************************************
 * Name          : gld_cb_destroy
 *
 * Description   : This function is invoked at destroy time. This function will
 *                 free all the dynamically allocated memory
 *
 * Arguments     : gld_cb  - GLD control block pointer.
 *
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
 *
 * Notes         : None.
 *****************************************************************************/
uns32 gld_cb_destroy(GLSV_GLD_CB *gld_cb)
{
	GLSV_GLD_GLND_DETAILS *node_details;
	GLSV_GLD_RSC_INFO *rsc_info;
	GLSV_NODE_LIST *node_list;
	GLSV_GLD_GLND_RSC_REF *glnd_rsc;

	/* destroy the patricia trees */
	while ((node_details = (GLSV_GLD_GLND_DETAILS *)ncs_patricia_tree_getnext(&gld_cb->glnd_details, (uns8 *)0))) {
		while ((glnd_rsc =
			(GLSV_GLD_GLND_RSC_REF *)ncs_patricia_tree_getnext(&node_details->rsc_info_tree, (uns8 *)0))) {
			if (ncs_patricia_tree_del(&node_details->rsc_info_tree, (NCS_PATRICIA_NODE *)glnd_rsc) !=
			    NCSCC_RC_SUCCESS) {
				m_LOG_GLD_HEADLINE(GLD_PATRICIA_TREE_DEL_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__,
						   0);
				return NCSCC_RC_FAILURE;
			}
			m_MMGR_FREE_GLSV_GLD_GLND_RSC_REF(glnd_rsc);
		}
		ncs_patricia_tree_destroy(&node_details->rsc_info_tree);
		if (ncs_patricia_tree_del(&gld_cb->glnd_details, (NCS_PATRICIA_NODE *)node_details) != NCSCC_RC_SUCCESS) {
			m_LOG_GLD_HEADLINE(GLD_PATRICIA_TREE_DEL_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__,
					   node_details->node_id);
			return NCSCC_RC_FAILURE;
		}

		m_MMGR_FREE_GLSV_GLD_GLND_DETAILS(node_details);
	}

	while ((rsc_info = (GLSV_GLD_RSC_INFO *)ncs_patricia_tree_getnext(&gld_cb->rsc_info_id, (uns8 *)0))) {
		/* Free the node list */
		while (rsc_info->node_list != NULL) {
			node_list = rsc_info->node_list;
			rsc_info->node_list = node_list->next;
			m_MMGR_FREE_GLSV_NODE_LIST(node_list);
		}

		gld_free_rsc_info(gld_cb, rsc_info);
	}
	return NCSCC_RC_SUCCESS;
}