Beispiel #1
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;
}
Beispiel #2
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;
}
Beispiel #3
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;
}
Beispiel #4
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
******************************************************************************/
uint32_t eda_create(NCS_LIB_CREATE *create_info)
{
    EDA_CB *cb = 0;
    uint32_t rc = NCSCC_RC_SUCCESS;
    TRACE_ENTER();

    if (NULL == create_info) {
        TRACE_LEAVE2("create_info is NULL");
        return NCSCC_RC_FAILURE;
    }

    /* allocate EDA cb */
    if (NULL == (cb = m_MMGR_ALLOC_EDA_CB)) {
        TRACE_4("malloc failed");
        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))) {
        TRACE_4("create handle failed");
        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;

    TRACE_1("global eda library handle is: %u", gl_eda_hdl);

    /* register with MDS */
    if ((NCSCC_RC_SUCCESS != (rc = eda_mds_init(cb)))) {
        TRACE_4("mds init failed");
        rc = NCSCC_RC_FAILURE;
        goto error;
    }

    eda_sync_with_eds(cb);
    cb->node_status = SA_CLM_NODE_JOINED;
    TRACE_LEAVE2("Default local node membership status: %u", cb->node_status);
    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);
    }
    TRACE_LEAVE();
    return rc;
}