コード例 #1
0
/****************************************************************************
  Name          : ntfa_filter_hdl_rec_del
 
  Description   : This routine deletes the a log stream handle record from
                  a list of log stream hdl records. 
 
  Arguments     : NTFA_filter_hdl_REC **list_head
                  NTFA_filter_hdl_REC *rm_node

 
  Return Values : None
 
  Notes         : 
******************************************************************************/
uns32 ntfa_filter_hdl_rec_del(ntfa_filter_hdl_rec_t **list_head, ntfa_filter_hdl_rec_t *rm_node)
{
	/* Find the filter hdl record in the list of records */
	ntfa_filter_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->filter_hdl);
		ncshm_destroy_hdl(NCS_SERVICE_ID_NTFA, rm_node->filter_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->filter_hdl);
				ncshm_destroy_hdl(NCS_SERVICE_ID_NTFA, rm_node->filter_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;
}
コード例 #2
0
ファイル: eds_evt.c プロジェクト: helioloureiro/opensaf-fork
static uint32_t eds_proc_eda_api_msg(EDSV_EDS_EVT *evt)
{
	EDS_CB *cb;
	TRACE_ENTER();

	if ((evt->info.msg.info.api_info.type >= EDSV_API_BASE_MSG) &&
	    (evt->info.msg.info.api_info.type < EDSV_API_MAX)) {
		/* Retrieve the cb handle */
		if (NULL == (cb = (EDS_CB *)ncshm_take_hdl(NCS_SERVICE_ID_EDS, evt->cb_hdl))) {
			TRACE_LEAVE();
			return NCSCC_RC_FAILURE;
		}

		if (eds_eda_api_msg_dispatcher[evt->info.msg.info.api_info.type] (cb, evt) != NCSCC_RC_SUCCESS) {
			ncshm_give_hdl(evt->cb_hdl);
			TRACE_LEAVE();
			return NCSCC_RC_FAILURE;
		}

		/* Give the cb handle back */
		ncshm_give_hdl(evt->cb_hdl);

	} else
		LOG_ER("Invalid API event received from agent dest %" PRIx64, evt->fr_dest);

	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
コード例 #3
0
/****************************************************************************
 * Name          : cpnd_saf_health_chk_callback
 *
 * Description   : This function SAF callback function which will be called 
 *                 when the AMF framework needs to health for the component.
 *
 * Arguments     : invocation     - This parameter designated a particular 
 *                                  invocation of this callback function. The
 *                                  invoke process return invocation when it 
 *                                  responds to the Availability Management 
 *                                  FrameWork using the saAmfResponse() 
 *                                  function.
 *                 compName       - A pointer to the name of the component 
 *                                  whose readiness stae the Availability 
 *                                  Management Framework is setting.
 *                 checkType      - The type of healthcheck to be executed. 
 *
 * Return Values : None
 *
 * Notes         : At present we are just support a simple liveness check.
 *****************************************************************************/
void
cpnd_saf_health_chk_callback(SaInvocationT invocation, const SaNameT *compName, const SaAmfHealthcheckKeyT *checkType)
{
	CPND_CB *cpnd_cb = NULL;
	SaAisErrorT error = SA_AIS_OK;
	uns32 cb_hdl = m_CPND_GET_CB_HDL;

	/* Get the CB from the handle */
	cpnd_cb = ncshm_take_hdl(NCS_SERVICE_ID_CPND, cb_hdl);

	if (!cpnd_cb) {
		m_LOG_CPND_CL(CPND_CB_HDL_TAKE_FAILED, CPND_FC_HDLN, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		return;
	}

	if (saAmfResponse(cpnd_cb->amf_hdl, invocation, error) != SA_AIS_OK) {
		m_LOG_CPND_CL(CPND_AMF_RESPONSE_FAILED, CPND_FC_HDLN, NCSFL_SEV_ERROR, __FILE__, __LINE__);
		ncshm_give_hdl(cb_hdl);
		return;
	}

	/* giveup the handle */
	ncshm_give_hdl(cb_hdl);
	return;
}
コード例 #4
0
ファイル: eds_evt.c プロジェクト: helioloureiro/opensaf-fork
/****************************************************************************
 * Name          : eds_proc_quiesced_ack_evt
 *
 * Description   : This is the function which is called when eds receives an
 *                       quiesced ack event from MDS 
 *
 * Arguments     : evt  - Message that was posted to the EDS Mail box.
 *
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t eds_proc_quiesced_ack_evt(EDSV_EDS_EVT *evt)
{
	EDS_CB *cb;
	TRACE_ENTER();

	/* Retrieve the cb handle */
	if (NULL == (cb = (EDS_CB *)ncshm_take_hdl(NCS_SERVICE_ID_EDS, evt->cb_hdl))) {
		TRACE_LEAVE();
		return NCSCC_RC_FAILURE;
	}

	if (cb->is_quisced_set == true) {
		cb->ha_state = SA_AMF_HA_QUIESCED;
		/* Inform MBCSV of HA state change */
		if (eds_mbcsv_change_HA_state(cb) != NCSCC_RC_SUCCESS) {
			TRACE("EDS-MBCSV change role failed");
		}

		/* Update control block */
		saAmfResponse(cb->amf_hdl, cb->amf_invocation_id, SA_AIS_OK);
		cb->is_quisced_set = false;
		/* Give the cb handle back */
		ncshm_give_hdl(evt->cb_hdl);
	} else {
		TRACE("Quiesced set is false");
		ncshm_give_hdl(evt->cb_hdl);
	}

	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
コード例 #5
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;
}
コード例 #6
0
ファイル: eda_hdl.c プロジェクト: kenzaburo/OpenSaf-FrameWork
/****************************************************************************
  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;
}
コード例 #7
0
/****************************************************************************
 * Name          : glsv_gld_standby_rsc_close
 *
 * Description   : This is the function is invoked when a rsc_close event is
 *                 is sent from avtive GLD to standby GLD. This function will
 *                  remove references to
 *                 to this resource from the mentioned node. If the resource
 *                 is not referred any longer then the data structures are freed
 *                 up.
 *
 * Arguments     : async_evt  - Event structure
 *
 * Return Values : NCSCC_RC_SUCCESS/ NCSCC_RC_FAILURE
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t glsv_gld_standby_rsc_close(GLSV_GLD_A2S_CKPT_EVT *async_evt)
{
	GLSV_GLD_CB *gld_cb;
	GLSV_GLD_GLND_DETAILS *node_details;
	GLSV_GLD_GLND_RSC_REF *glnd_rsc;
	bool orphan_flag;
	uint32_t node_id;
	uint32_t rc = NCSCC_RC_FAILURE;
	TRACE_ENTER();

	if (async_evt == NULL)
		goto end;
	node_id = m_NCS_NODE_ID_FROM_MDS_DEST(async_evt->info.rsc_details.mdest_id);

	if ((gld_cb = (NCSCONTEXT)ncshm_take_hdl(NCS_SERVICE_ID_GLD, gl_gld_hdl))
	    == NULL) {
		LOG_ER("Handle take failed");
		goto end;
	}

	orphan_flag = async_evt->info.rsc_details.orphan;

	/* Find if the node details are available */
	if ((node_details =
	     (GLSV_GLD_GLND_DETAILS *)ncs_patricia_tree_get(&gld_cb->glnd_details, (uint8_t *)&node_id)) == NULL) {
		LOG_ER("Patricia tree get failed: node_id %u", node_id);
		goto error;
	}

	glnd_rsc = (GLSV_GLD_GLND_RSC_REF *)ncs_patricia_tree_get(&node_details->rsc_info_tree,
								  (uint8_t *)&async_evt->info.rsc_details.rsc_id);
	if (glnd_rsc == NULL) {
		LOG_ER("Patricia tree get failed");
		goto error;

	}

	glnd_rsc->rsc_info->saf_rsc_no_of_users = glnd_rsc->rsc_info->saf_rsc_no_of_users - 1;

	if (async_evt->info.rsc_details.lcl_ref_cnt == 0)
		gld_rsc_rmv_node_ref(gld_cb, glnd_rsc->rsc_info, glnd_rsc, node_details, orphan_flag);

	TRACE_1("GLD a2s evt rsc close success: rsc_id %u node_id %u",
		      async_evt->info.rsc_details.rsc_id, node_id);
	ncshm_give_hdl(gld_cb->my_hdl);
	rc = NCSCC_RC_SUCCESS;
	goto end;
 error:
	LOG_ER("GLD a2s evt rsc close failed: rsc_id %u node_id %u",
		      async_evt->info.rsc_details.rsc_id, node_id);
	ncshm_give_hdl(gld_cb->my_hdl);
 end:	
	TRACE_LEAVE();
	return rc;
}
コード例 #8
0
ファイル: eda_hdl.c プロジェクト: kenzaburo/OpenSaf-FrameWork
/****************************************************************************
  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;
}
コード例 #9
0
ファイル: eda_hdl.c プロジェクト: kenzaburo/OpenSaf-FrameWork
/****************************************************************************
  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;
}
コード例 #10
0
ファイル: eds_evt.c プロジェクト: helioloureiro/opensaf-fork
/****************************************************************************
 * Name          : eds_process_evt
 *
 * Description   : This is the function which is called when eds receives an
 *                 event of any kind.
 *
 * Arguments     : msg  - Message that was posted to the EDS Mail box.
 *
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 *
 * Notes         : None.
 *****************************************************************************/
uint32_t eds_process_evt(EDSV_EDS_EVT *evt)
{
	EDS_CB *cb;
	TRACE_ENTER();

	/* Retrieve the cb handle */
	if (NULL == (cb = (EDS_CB *)ncshm_take_hdl(NCS_SERVICE_ID_EDS, evt->cb_hdl))) {
		TRACE_LEAVE();
		return NCSCC_RC_FAILURE;
	}

	if (cb->ha_state == SA_AMF_HA_ACTIVE) {
		if ((evt->evt_type >= EDSV_EDS_EVT_BASE) && (evt->evt_type <= EDSV_EDS_RET_TIMER_EXP)) {
	  /** Invoke the evt dispatcher **/
			eds_edsv_top_level_evt_dispatch_tbl[evt->evt_type] (evt);
		} else if (evt->evt_type == EDSV_EVT_QUIESCED_ACK) {
			eds_proc_quiesced_ack_evt(evt);
		} else
			TRACE("Event processing failed");
	} else {
		if ((evt->evt_type == EDSV_EDS_RET_TIMER_EXP) || (evt->evt_type == EDSV_EDS_EVT_EDA_DOWN))
	    /** Invoke the evt dispatcher **/
			eds_edsv_top_level_evt_dispatch_tbl[evt->evt_type] (evt);
	}

	ncshm_give_hdl(evt->cb_hdl);
	/* Free the event */
	if (NULL != evt)
		eds_evt_destroy(evt);

	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
コード例 #11
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;
}
コード例 #12
0
ファイル: eda_init.c プロジェクト: helioloureiro/opensaf-fork
/****************************************************************************
  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;
}
コード例 #13
0
ファイル: gld_tmr.c プロジェクト: kenzaburo/OpenSaf-FrameWork
/*****************************************************************************
  PROCEDURE NAME : gld_tmr_exp

  DESCRIPTION    : GLD timer expiry callback routine.It sends corresponding
                  timer events to GLD.

  ARGUMENTS      : uarg - ptr to the GLD timer block

  RETURNS        : void

  NOTES         : None
*****************************************************************************/
void gld_tmr_exp(void *uarg)
{
	GLSV_GLD_CB *cb = 0;
	GLD_TMR *tmr = (GLD_TMR *)uarg;
	GLSV_GLD_EVT *evt = 0;
	uns32 cb_hdl;

	cb_hdl = tmr->cb_hdl;
	/* retrieve GLD CB */
	cb = (GLSV_GLD_CB *)ncshm_take_hdl(NCS_SERVICE_ID_GLD, tmr->cb_hdl);
	if (!cb) {
		m_LOG_GLD_HEADLINE(GLD_TAKE_HANDLE_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0);
		return;
	}

	tmr->is_active = FALSE;

	/* create & send the timer event */
	evt = m_MMGR_ALLOC_GLSV_GLD_EVT;
	if (evt == GLSV_GLD_EVT_NULL) {
		m_LOG_GLD_MEMFAIL(GLD_EVT_ALLOC_FAILED, __FILE__, __LINE__);
		ncshm_give_hdl(cb_hdl);
		return;
	}
	memset(evt, 0, sizeof(GLSV_GLD_EVT));
	if (evt) {
		/* assign the timer evt */
		evt->evt_type = gld_tmr_evt_map(tmr->type);
		evt->info.tmr.opq_hdl = tmr->opq_hdl;
		evt->info.tmr.resource_id = tmr->resource_id;
		memcpy(&evt->info.tmr.mdest_id, &tmr->mdest_id, sizeof(MDS_DEST));
		evt->gld_cb = cb;
		/* Push the event and we are done */
		if (m_NCS_IPC_SEND(&cb->mbx, evt, NCS_IPC_PRIORITY_NORMAL) == NCSCC_RC_FAILURE) {
			m_LOG_GLD_HEADLINE(GLD_IPC_SEND_FAIL, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0);
			gld_evt_destroy(evt);
			ncshm_give_hdl(cb_hdl);
			return;
		}

	}

	/* return GLD CB */
	ncshm_give_hdl(cb_hdl);

	return;
}
コード例 #14
0
ファイル: cpa_mds.c プロジェクト: kenzaburo/OpenSaf-FrameWork
/****************************************************************************
  Name          : cpa_mds_callback
 
  Description   : This callback routine will be called by MDS on event arrival
 
  Arguments     : info - pointer to the mds callback info
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uns32 cpa_mds_callback(struct ncsmds_callback_info *info)
{
	CPA_CB *cpa_cb = NULL;
	uns32 rc = NCSCC_RC_FAILURE;

	if (info == NULL)
		return rc;

	cpa_cb = (CPA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_CPA, gl_cpa_hdl);

	if (!cpa_cb) {
		m_LOG_CPA_CCLL(CPA_PROC_FAILED, NCSFL_LC_CKPT_MGMT, NCSFL_SEV_ERROR, "mds_callback:HDL_TAKE", __FILE__,
			       __LINE__, rc);
		return m_LEAP_DBG_SINK(rc);
	}

	switch (info->i_op) {
	case MDS_CALLBACK_COPY:
		rc = NCSCC_RC_FAILURE;
		break;

	case MDS_CALLBACK_ENC_FLAT:
		rc = cpa_mds_enc_flat(cpa_cb, &info->info.enc_flat);
		break;

	case MDS_CALLBACK_DEC_FLAT:
		rc = cpa_mds_dec_flat(cpa_cb, &info->info.dec_flat);
		break;
	case MDS_CALLBACK_RECEIVE:
		rc = cpa_mds_rcv(cpa_cb, &info->info.receive);
		break;

	case MDS_CALLBACK_SVC_EVENT:
		rc = cpa_mds_svc_evt(cpa_cb, &info->info.svc_evt);
		break;

	case MDS_CALLBACK_ENC:
		rc = cpa_mds_enc(cpa_cb, &info->info.enc);
		break;

	case MDS_CALLBACK_DEC:
		rc = cpa_mds_dec(cpa_cb, &info->info.dec);
		break;

	default:
		m_LOG_CPA_CCLL(CPA_PROC_FAILED, NCSFL_LC_CKPT_MGMT, NCSFL_SEV_INFO, "mds_callback:unknown_op", __FILE__,
			       __LINE__, rc);
		break;
	}

	if (rc != NCSCC_RC_SUCCESS) {
		m_LOG_CPA_CCLL(CPA_PROC_FAILED, NCSFL_LC_CKPT_MGMT, NCSFL_SEV_INFO, "mds_callback", __FILE__, __LINE__,
			       rc);
	}

	ncshm_give_hdl(gl_cpa_hdl);

	return rc;
}
コード例 #15
0
/****************************************************************************
  Name          : mqnd_mds_callback
 
  Description   : This callback routine will be called by MDS on event arrival
 
  Arguments     : info - pointer to the mds callback info
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
static uns32 mqnd_mds_callback(struct ncsmds_callback_info *info)
{
	MQND_CB *cb = NULL;
	uns32 rc = NCSCC_RC_SUCCESS;

	if (info == NULL) {
		rc = NCSCC_RC_FAILURE;
		return rc;
	}

	cb = (MQND_CB *)ncshm_take_hdl(NCS_SERVICE_ID_MQND, (uns32)info->i_yr_svc_hdl);
	if (!cb) {
		rc = NCSCC_RC_FAILURE;
		m_LOG_MQSV_ND(MQND_CB_HDL_TAKE_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__);
		return rc;
	}

	switch (info->i_op) {
	case MDS_CALLBACK_COPY:
		mqnd_mds_cpy(cb, &info->info.cpy);
		break;

	case MDS_CALLBACK_ENC:
		rc = mqnd_mds_enc(cb, &info->info.enc);
		break;
	case MDS_CALLBACK_DEC:
		rc = mqnd_mds_dec(cb, &info->info.dec);
		break;
	case MDS_CALLBACK_ENC_FLAT:
		rc = mqnd_mds_enc(cb, &info->info.enc_flat);
		break;
	case MDS_CALLBACK_DEC_FLAT:
		rc = mqnd_mds_dec(cb, &info->info.dec_flat);
		break;
	case MDS_CALLBACK_RECEIVE:
		rc = mqnd_mds_rcv(cb, &info->info.receive);
		break;

	case MDS_CALLBACK_SVC_EVENT:
		rc = mqnd_mds_svc_evt(cb, &info->info.svc_evt);
		break;

	case MDS_CALLBACK_DIRECT_RECEIVE:
		rc = mqnd_mds_direct_rcv(cb, &info->info.direct_receive);
		break;

	default:
		rc = NCSCC_RC_FAILURE;
		break;
	}
	if (rc == NCSCC_RC_SUCCESS)
		m_LOG_MQSV_ND(MQND_MDS_CLBK_COMPLETE, NCSFL_LC_MQSV_INIT, NCSFL_SEV_INFO, info->i_op, __FILE__,
			      __LINE__);
	else
		m_LOG_MQSV_ND(MQND_MDS_CLBK_COMPLETE, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, info->i_op, __FILE__,
			      __LINE__);
	ncshm_give_hdl((uns32)info->i_yr_svc_hdl);
	return rc;
}
コード例 #16
0
ファイル: eds_api.c プロジェクト: helioloureiro/opensaf-fork
/****************************************************************************
 * 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);
}
コード例 #17
0
ファイル: eds_evt.c プロジェクト: helioloureiro/opensaf-fork
/****************************************************************************
 * Name          : eds_proc_ret_tmr_exp_evt
 *
 * Description   : This is the function which is called when eds receives any
 *                 a retention tmr expiry evt
 *
 * Arguments     : evt  - Evt that was posted to the EDS Mail box.
 *
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t eds_proc_ret_tmr_exp_evt(EDSV_EDS_EVT *evt)
{
	EDS_RETAINED_EVT_REC *ret_evt;
	uint32_t rc = NCSCC_RC_SUCCESS;
	EDS_CB *eds_cb;
	TRACE_ENTER();

	/* retrieve retained evt */
	if (NULL == (eds_cb = (EDS_CB *)ncshm_take_hdl(NCS_SERVICE_ID_EDS, evt->cb_hdl))) {
		TRACE_LEAVE2("take handle failed for cb");
		return NCSCC_RC_FAILURE;
	}

	/* retrieve retained evt */
	if (NULL == (ret_evt = (EDS_RETAINED_EVT_REC *)ncshm_take_hdl(NCS_SERVICE_ID_EDS, evt->info.tmr_info.opq_hdl))) {
		TRACE_LEAVE2("take handle failed for retained evt rec.");
		return NCSCC_RC_FAILURE;
	}

	m_NCS_LOCK(&eds_cb->cb_lock, NCS_LOCK_WRITE);

   /** store the chan id as we would need it
    ** after the event is freed
    **/

/* CHECKPOINT:
   if ( EDS_CB->ha_state == standby)
        compose a EDSV_CKPT_RETENTION_TIME_CLEAR_MSG and send to standby peer. 
*/
   /** This also frees the event **/
	rc = eds_clear_retained_event(eds_cb,
				      ret_evt->chan_id, ret_evt->retd_evt_chan_open_id, ret_evt->event_id, true);

	m_NCS_UNLOCK(&eds_cb->cb_lock, NCS_LOCK_WRITE);

	if (NCSCC_RC_SUCCESS != rc) {
		ncshm_give_hdl(evt->info.tmr_info.opq_hdl);
		ncshm_give_hdl(evt->cb_hdl);
		TRACE_LEAVE();
		return rc;
	}

	ncshm_give_hdl(evt->cb_hdl);
	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
コード例 #18
0
/****************************************************************************
 * Name          : glsv_gld_standby_rsc_set_orphan
 *
 * Description   : Instruction from the GLND to set the orphan flag
 *
 * Arguments     : async_evt  - Event structure
 *
 * Return Values : NCSCC_RC_SUCCESS/ NCSCC_RC_FAILURE
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t glsv_gld_standby_rsc_set_orphan(GLSV_GLD_A2S_CKPT_EVT *async_evt)
{
	GLSV_GLD_CB *gld_cb;
	GLSV_GLD_GLND_DETAILS *node_details;
	uint32_t node_id;
	uint32_t rc = NCSCC_RC_FAILURE;
	TRACE_ENTER();

	if (async_evt == NULL)
		goto end;

	node_id = m_NCS_NODE_ID_FROM_MDS_DEST(async_evt->info.rsc_details.mdest_id);

	if ((gld_cb = (NCSCONTEXT)ncshm_take_hdl(NCS_SERVICE_ID_GLD, gl_gld_hdl))
	    == NULL) {
		LOG_ER("Handle take failed");
		goto end;
	}

	/* Find if the node details are available */
	if ((node_details =
	     (GLSV_GLD_GLND_DETAILS *)ncs_patricia_tree_get(&gld_cb->glnd_details, (uint8_t *)&node_id)) == NULL) {
		LOG_ER("Patricia tree get failed: node_id %u", node_id);
		goto error;
	}
	if (gld_rsc_ref_set_orphan(node_details, async_evt->info.rsc_details.rsc_id,
				   async_evt->info.rsc_details.orphan,
				   async_evt->info.rsc_details.lck_mode) == NCSCC_RC_SUCCESS) {
		TRACE_1("GLD a2s evt set orphan success: rsc_id %u node_id %u",
			      async_evt->info.rsc_details.rsc_id, node_id);
		ncshm_give_hdl(gld_cb->my_hdl);
		rc = NCSCC_RC_SUCCESS;
		goto end;
	} else
		goto error;

 error:
	LOG_ER("GLD a2s evt set orphan failed: rsc_id %u node_id %u",
		      async_evt->info.rsc_details.rsc_id, node_id);
	ncshm_give_hdl(gld_cb->my_hdl);
 end:
	TRACE_LEAVE();
	return rc;

}
コード例 #19
0
ファイル: ava_hdl.c プロジェクト: helioloureiro/opensaf-fork
/****************************************************************************
  Name          : ava_hdl_cbk_dispatch_one
 
  Description   : This routine dispatches one pending callback.
 
  Arguments     : cb      - ptr to the AvA control block
                  hdl_rec - ptr to the handle record
 
  Return Values : SA_AIS_OK/SA_AIS_ERR_<CODE>
 
  Notes         : None.
******************************************************************************/
uint32_t ava_hdl_cbk_dispatch_one(AVA_CB **cb, AVA_HDL_REC **hdl_rec)
{
	AVA_PEND_RESP *list_resp = &(*hdl_rec)->pend_resp;
	AVA_PEND_CBK_REC *rec = 0;
	uint32_t hdl = (*hdl_rec)->hdl;
	SaAmfCallbacksT reg_cbk;
	uint32_t rc = SA_AIS_OK;
	TRACE_ENTER();

	memset(&reg_cbk, 0, sizeof(SaAmfCallbacksT));
	memcpy(&reg_cbk, &(*hdl_rec)->reg_cbk, sizeof(SaAmfCallbacksT));

	/* pop the rec from the mailbox queue */
	rec = (AVA_PEND_CBK_REC *)m_NCS_IPC_NON_BLK_RECEIVE(&(*hdl_rec)->callbk_mbx, NULL);

	if (rec) {

		if (rec->cbk_info->type != AVSV_AMF_PG_TRACK) {
			/* push this record into pending response list */
			m_AVA_HDL_PEND_RESP_PUSH(list_resp, (AVA_PEND_RESP_REC *)rec);
			m_AVA_HDL_CBK_REC_IN_DISPATCH_SET(rec);
		}

		/* release the cb lock & return the hdls to the hdl-mngr */
		m_NCS_UNLOCK(&(*cb)->lock, NCS_LOCK_WRITE);
		ncshm_give_hdl(hdl);

		/* process the callback list record */
		ava_hdl_cbk_rec_prc(rec->cbk_info, &reg_cbk);

		m_NCS_LOCK(&(*cb)->lock, NCS_LOCK_WRITE);

		if (0 == (*hdl_rec = ncshm_take_hdl(NCS_SERVICE_ID_AVA, hdl))) {
			/* hdl is already finalized */
			ava_hdl_cbk_rec_del(rec);
			TRACE_LEAVE2("Handle is already finalized");
			return rc;
		}

		/* if we are done with this rec, free it */
		if ((rec->cbk_info->type != AVSV_AMF_PG_TRACK) && m_AVA_HDL_IS_CBK_RESP_DONE(rec)) {
			m_AVA_HDL_PEND_RESP_POP(list_resp, rec, rec->cbk_info->inv);
			ava_hdl_cbk_rec_del(rec);
		} else if (rec->cbk_info->type == AVSV_AMF_PG_TRACK) {
			/* PG Track cbk do not have any response */
			ava_hdl_cbk_rec_del(rec);
		} else {
			m_AVA_HDL_CBK_REC_IN_DISPATCH_RESET(rec);
		}

	}
	else
		TRACE_3("No record to process the dispatch()");

	TRACE_LEAVE();
	return rc;
}
コード例 #20
0
ファイル: eda_hdl.c プロジェクト: kenzaburo/OpenSaf-FrameWork
/****************************************************************************
 
  Name          : eda_find_subsc_validity
  Description   : This routine finds out whether the callback 
                  is for valid subscriber or not .
 
  Arguments     : cb      - ptr to the EDA control block
                  cbk_msg - ptr to the callback msg 
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
static uns32 eda_find_subsc_validity(EDA_CB *cb, EDSV_MSG *cbk_msg)
{
	EDA_CHANNEL_HDL_REC *chan_hdl_rec = NULL;
	EDA_EVENT_HDL_REC *evt_hdl_rec = NULL;
	EDSV_EDA_EVT_DELIVER_CBK_PARAM *evt_dlv_param = &cbk_msg->info.cbk_info.param.evt_deliver_cbk;
	SaEvtEventHandleT eventHandle = evt_dlv_param->event_hdl;
   /** Lookup the hdl rec 
    **/
	/* retrieve event hdl record */
	if (NULL == (evt_hdl_rec = (EDA_EVENT_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_EDA, eventHandle))) {
		m_LOG_EDSV_A(EDA_FAILURE, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, eventHandle, __FILE__, __LINE__, 0);
		return NCSCC_RC_FAILURE;
	}
	if (evt_hdl_rec->parent_chan) {	/* Check if channel still exists */
		if (evt_hdl_rec->parent_chan->channel_hdl) {
			/* retrieve the eda channel hdl record */
			if (NULL !=
			    (chan_hdl_rec =
			     (EDA_CHANNEL_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_EDA,
								   evt_hdl_rec->parent_chan->channel_hdl))) {
				if (NULL != eda_find_subsc_by_subsc_id(chan_hdl_rec, evt_dlv_param->sub_id)) {
					ncshm_give_hdl(eventHandle);
					ncshm_give_hdl(chan_hdl_rec->channel_hdl);
					return NCSCC_RC_SUCCESS;
				} else {
					if (chan_hdl_rec->subsc_list) {
						ncshm_give_hdl(eventHandle);
						ncshm_give_hdl(chan_hdl_rec->channel_hdl);
						return NCSCC_RC_SUCCESS;
					} else {
		    /** Lock EDA_CB synchronize access with MDS thread.
                     **/
						m_NCS_LOCK(&cb->cb_lock, NCS_LOCK_WRITE);

		     /** Delete this evt record from the
                      ** list of events
                      **/
						if (NCSCC_RC_SUCCESS !=
						    eda_event_hdl_rec_del(&chan_hdl_rec->chan_event_anchor,
									  evt_hdl_rec)) {
							ncshm_give_hdl(eventHandle);
						}
						m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
						ncshm_give_hdl(chan_hdl_rec->channel_hdl);
						return NCSCC_RC_FAILURE;

					}

				}
			}
		}
	}

	ncshm_give_hdl(eventHandle);
	return NCSCC_RC_FAILURE;

}
コード例 #21
0
/****************************************************************************
 * Name          : glsv_gld_glnd_operational
 *
 * Description   : MDS indicated that a glnd has gone down
 *
 * Arguments     : async_evt  - Event structure
 *
 * Return Values : NCSCC_RC_SUCCESS/ NCSCC_RC_FAILURE
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t glsv_gld_standby_glnd_operational(GLSV_GLD_A2S_CKPT_EVT *async_evt)
{
	GLSV_GLD_CB *gld_cb = NULL;
	GLSV_GLD_GLND_DETAILS *node_details = NULL;
	GLSV_GLD_RSC_INFO *rsc_info = NULL;
	GLSV_NODE_LIST *node_list = NULL;
	uint32_t node_id;
	uint32_t rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();

	if (async_evt == NULL) {
		rc = NCSCC_RC_FAILURE;
		goto end;
	}

	node_id = m_NCS_NODE_ID_FROM_MDS_DEST(async_evt->info.glnd_mds_info.mdest_id);

	if ((gld_cb = (NCSCONTEXT)ncshm_take_hdl(NCS_SERVICE_ID_GLD, gl_gld_hdl))
	    == NULL) {
		LOG_ER("Handle take failed");
		rc = NCSCC_RC_FAILURE;
		goto end;	
	}

	if ((node_details = (GLSV_GLD_GLND_DETAILS *)ncs_patricia_tree_get(&gld_cb->glnd_details,
									   (uint8_t *)&node_id)) != NULL) {
		memcpy(&node_details->dest_id, &async_evt->info.glnd_mds_info.mdest_id, sizeof(MDS_DEST));

		/* Cancel the restart timer if started */
		gld_stop_tmr(&node_details->restart_timer);

		node_details->status = GLND_OPERATIONAL_STATE;

		rsc_info = gld_cb->rsc_info;

		while (rsc_info != NULL) {
			node_list = rsc_info->node_list;
			while (node_list != NULL) {
				if (node_list->node_id == node_id) {
					memcpy(&node_list->dest_id, &async_evt->info.glnd_mds_info.mdest_id,
					       sizeof(MDS_DEST));
				}
				node_list = node_list->next;
			}
			rsc_info = rsc_info->next;
		}
	}

	ncshm_give_hdl(gld_cb->my_hdl);
 end:
	TRACE_LEAVE();
	return rc;
}
コード例 #22
0
ファイル: tet_glnd.c プロジェクト: helioloureiro/opensaf-fork
void print_glnd_cb() {

   GLND_CB           *cb;
   GLSV_GLND_EVT     *glnd_evt;
                                                                                
   glnd_evt = m_MMGR_ALLOC_GLND_EVT;
   memset(glnd_evt,0,sizeof(GLSV_GLND_EVT));
   glnd_evt->type = GLSV_GLND_EVT_CB_DUMP;
                                                                                
   cb =   (GLND_CB*)ncshm_take_hdl(NCS_SERVICE_ID_GLND, m_GLND_RETRIEVE_GLND_CB_HDL);
   glnd_evt->glnd_hdl = cb->cb_hdl_id;
   m_NCS_IPC_SEND(&cb->glnd_mbx, glnd_evt, MDS_SEND_PRIORITY_MEDIUM);
   ncshm_give_hdl(gl_glnd_hdl);
}
コード例 #23
0
ファイル: cpd_amf.c プロジェクト: indonexia2004/opensaf-indo
/****************************************************************************
 * Name          : cpd_amf_comp_terminate_callback
 *
 * Description   : This function SAF callback function which will be called 
 *                 when the AMF framework needs to terminate GLSV. This does
 *                 all required to destroy GLSV(except to unregister from AMF)
 *
 * Arguments     : invocation     - This parameter designated a particular 
 *                                  invocation of this callback function. The
 *                                  invoke process return invocation when it 
 *                                  responds to the Avilability Management 
 *                                  FrameWork using the saAmfResponse() 
 *                                  function.
 *                 compName       - A pointer to the name of the component 
 *                                  whose readiness stae the Availability 
 *                                  Management Framework is setting.
 *
 * Return Values : None
 *
 * Notes         : At present we are just support a simple liveness check.
 *****************************************************************************/
void cpd_amf_comp_terminate_callback(SaInvocationT invocation, const SaNameT *compName)
{
	CPD_CB *cb = 0;
	SaAisErrorT saErr = SA_AIS_OK;
	TRACE_ENTER();
	cb = ncshm_take_hdl(NCS_SERVICE_ID_CPD, gl_cpd_cb_hdl);
	if (cb) {
		saAmfResponse(cb->amf_hdl, invocation, saErr);
		ncshm_give_hdl(cb->cpd_hdl);
	}
	LOG_NO("Received AMF component terminate callback, exiting");
	TRACE_LEAVE();
	exit(0);
}
コード例 #24
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;
}
コード例 #25
0
ファイル: eds_tmr.c プロジェクト: kenzaburo/OpenSaf-FrameWork
/*****************************************************************************
  PROCEDURE NAME : eds_tmr_exp

  DESCRIPTION    : EDS timer expiry callback routine.It sends corresponding
                   timer events to EDS.

  ARGUMENTS      : uarg - ptr to the EDS timer block

  RETURNS        : void

  NOTES         : None
*****************************************************************************/
void eds_tmr_exp(void *uarg)
{
	EDS_CB *eds_cb = 0;
	EDS_TMR *tmr = (EDS_TMR *)uarg;
	EDSV_EDS_EVT *evt = 0;
	uns32 temp_tmr_hdl;

	temp_tmr_hdl = tmr->cb_hdl;

	/* retrieve EDS CB */
	if (NULL == (eds_cb = (EDS_CB *)ncshm_take_hdl(NCS_SERVICE_ID_EDS, tmr->cb_hdl))) {
		m_LOG_EDSV_S(EDS_CB_TAKE_HANDLE_FAILED, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__, 0);
		return;
	}

	if (tmr->is_active) {
		tmr->is_active = FALSE;
		/* Destroy the timer if it exists.. */
		if (tmr->tmr_id != TMR_T_NULL) {
			m_NCS_TMR_DESTROY(tmr->tmr_id);
			tmr->tmr_id = TMR_T_NULL;
		}

		/* create & send the timer event */
		evt = m_MMGR_ALLOC_EDSV_EDS_EVT;
		if (evt) {
			memset(evt, '\0', sizeof(EDSV_EDS_EVT));

			/* assign the timer evt */
			evt->evt_type = eds_tmr_evt_map(tmr->type);
			evt->info.tmr_info.opq_hdl = tmr->opq_hdl;

			evt->cb_hdl = tmr->cb_hdl;

			if (NCSCC_RC_FAILURE == m_NCS_IPC_SEND(&eds_cb->mbx, evt, NCS_IPC_PRIORITY_HIGH)) {
				m_LOG_EDSV_S(EDS_TIMER_STOP_FAIL, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, evt->cb_hdl,
					     __FILE__, __LINE__, evt->evt_type);
				eds_evt_destroy(evt);
			}

		}

	}

	/* return EDS CB */
	ncshm_give_hdl(temp_tmr_hdl);

	return;
}
コード例 #26
0
ファイル: cpd_amf.c プロジェクト: indonexia2004/opensaf-indo
/****************************************************************************
 PROCEDURE NAME : cpd_saf_hlth_chk_cb

 DESCRIPTION    : This function SAF callback function which will be called 
                  when the AMF framework needs to health for the component.
 
 ARGUMENTS      : invocation     - This parameter designated a particular 
                                   invocation of this callback function. The
                                   invoke process return invocation when it 
                                   responds to the Avilability Management 
                                   FrameWork using the saAmfResponse() 
                                   function.
                  compName       - A pointer to the name of the component 
                                   whose readiness stae the Availability 
                                   Management Framework is setting.
                  checkType      - The type of healthcheck to be executed. 
 
  RETURNS       : None 
  NOTES         : At present we are just support a simple liveness check.
*****************************************************************************/
void cpd_saf_hlth_chk_cb(SaInvocationT invocation, const SaNameT *compName, SaAmfHealthcheckKeyT *checkType)
{
	CPD_CB *cb = 0;
	SaAisErrorT saErr = SA_AIS_OK;
	
	/* Get the COntrol Block Pointer */
	cb = ncshm_take_hdl(NCS_SERVICE_ID_CPD, gl_cpd_cb_hdl);
	if (cb) {
		saAmfResponse(cb->amf_hdl, invocation, saErr);
		ncshm_give_hdl(cb->cpd_hdl);
	} else {
		LOG_ER("Failed to retrieve cpd handle %u",gl_cpd_cb_hdl);
	}
	return;
}	/* End of cpd_saf_hlth_chk_cb() */
コード例 #27
0
ファイル: eds_tmr.c プロジェクト: helioloureiro/opensaf-fork
/*****************************************************************************
  PROCEDURE NAME : eds_tmr_exp

  DESCRIPTION    : EDS timer expiry callback routine.It sends corresponding
                   timer events to EDS.

  ARGUMENTS      : uarg - ptr to the EDS timer block

  RETURNS        : void

  NOTES         : None
*****************************************************************************/
void eds_tmr_exp(void *uarg)
{
	EDS_CB *eds_cb = 0;
	EDS_TMR *tmr = (EDS_TMR *)uarg;
	EDSV_EDS_EVT *evt = 0;
	uint32_t temp_tmr_hdl;

	temp_tmr_hdl = tmr->cb_hdl;

	/* retrieve EDS CB */
	if (NULL == (eds_cb = (EDS_CB *)ncshm_take_hdl(NCS_SERVICE_ID_EDS, tmr->cb_hdl))) {
		LOG_ER("Global take handle failed");
		return;
	}

	if (tmr->is_active) {
		tmr->is_active = false;
		/* Destroy the timer if it exists.. */
		if (tmr->tmr_id != TMR_T_NULL) {
			m_NCS_TMR_DESTROY(tmr->tmr_id);
			tmr->tmr_id = TMR_T_NULL;
		}

		/* create & send the timer event */
		evt = m_MMGR_ALLOC_EDSV_EDS_EVT;
		if (evt) {
			memset(evt, '\0', sizeof(EDSV_EDS_EVT));

			/* assign the timer evt */
			evt->evt_type = eds_tmr_evt_map(tmr->type);
			evt->info.tmr_info.opq_hdl = tmr->opq_hdl;

			evt->cb_hdl = tmr->cb_hdl;

			if (NCSCC_RC_FAILURE == m_NCS_IPC_SEND(&eds_cb->mbx, evt, NCS_IPC_PRIORITY_HIGH)) {
				LOG_ER("IPC send failed for timer event");
				eds_evt_destroy(evt);
			}

		}

	}

	/* return EDS CB */
	ncshm_give_hdl(temp_tmr_hdl);

	return;
}
コード例 #28
0
ファイル: avnd_su.c プロジェクト: kenzaburo/OpenSaf-FrameWork
/****************************************************************************
  Name          : avnd_evt_tmr_su_err_esc
 
  Description   : This routine handles the the expiry of the 'su error 
                  escalation' timer. It indicates the end of the comp/su 
                  restart probation period for the SU.
 
  Arguments     : cb  - ptr to the AvND control block
                  evt - ptr to the AvND event
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uns32 avnd_evt_tmr_su_err_esc_evh(AVND_CB *cb, AVND_EVT *evt)
{
	AVND_SU *su;
	uns32 rc = NCSCC_RC_SUCCESS;

	TRACE_ENTER();

	/* retrieve avnd cb */
	if (0 == (su = (AVND_SU *)ncshm_take_hdl(NCS_SERVICE_ID_AVND, (uns32)evt->info.tmr.opq_hdl))) {
		LOG_CR("Unable to retrieve handle");
		goto done;
	}

	TRACE("'%s'", su->name.value);

	if (NCSCC_RC_SUCCESS == m_AVND_CHECK_FOR_STDBY_FOR_EXT_COMP(cb, su->su_is_external))
		goto done;

	m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, su, AVND_CKPT_SU_ERR_ESC_TMR);

	switch (su->su_err_esc_level) {
	case AVND_ERR_ESC_LEVEL_0:
		su->comp_restart_cnt = 0;
		su->su_err_esc_level = AVND_ERR_ESC_LEVEL_0;
		m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, su, AVND_CKPT_SU_COMP_RESTART_CNT);
		break;
	case AVND_ERR_ESC_LEVEL_1:
		su->su_restart_cnt = 0;
		su->su_err_esc_level = AVND_ERR_ESC_LEVEL_0;
		cb->node_err_esc_level = AVND_ERR_ESC_LEVEL_0;
		m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, su, AVND_CKPT_SU_RESTART_CNT);
		break;
	case AVND_ERR_ESC_LEVEL_2:
		cb->su_failover_cnt = 0;
		su->su_err_esc_level = AVND_ERR_ESC_LEVEL_0;
		cb->node_err_esc_level = AVND_ERR_ESC_LEVEL_0;
		break;
	default:
		assert(0);
	}
	m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, su, AVND_CKPT_SU_ERR_ESC_LEVEL);

done:
	if (su)
		ncshm_give_hdl((uns32)evt->info.tmr.opq_hdl);
	TRACE_LEAVE();
	return rc;
}
コード例 #29
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;
}
コード例 #30
0
ファイル: gld_api.c プロジェクト: kenzaburo/OpenSaf-FrameWork
/****************************************************************************
 * Name          : gld_dump_cb
 *
 * Description   : This is the function dumps the contents of the control block.
 *
 * Arguments     : gld_cb  -  Pointer to the control block
 *
 * Return Values : None.
 *
 * Notes         : None.
 *****************************************************************************/
void gld_dump_cb()
{
	GLSV_GLD_CB *gld_cb = NULL;
	GLSV_GLD_GLND_DETAILS *node_details;
	MDS_DEST mds_dest_id;
	GLSV_GLD_RSC_INFO *rsc_info;
	SaLckResourceIdT rsc_id = 0;
	uns32 node_id = 0;

	gld_cb = (NCSCONTEXT)ncshm_take_hdl(NCS_SERVICE_ID_GLD, gl_gld_hdl);
	if (!gld_cb) {
		m_LOG_GLD_HEADLINE(GLD_TAKE_HANDLE_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0);
		return;
	}

	memset(&mds_dest_id, 0, sizeof(MDS_DEST));

	TRACE("************ GLD CB info *************** ");
	/* print Amf Info */
	TRACE("AMF HA state : %d ", gld_cb->ha_state);
	/* print the Node details */
	TRACE("GLND info :");
	while ((node_details = (GLSV_GLD_GLND_DETAILS *)ncs_patricia_tree_getnext(&gld_cb->glnd_details,
										  (uns8 *)&node_id))) {
		node_id = node_details->node_id;
		TRACE("Node Id - :%d ", node_details->node_id);
	}

	/* print the Resource details */
	while ((rsc_info = (GLSV_GLD_RSC_INFO *)ncs_patricia_tree_getnext(&gld_cb->rsc_info_id, (uns8 *)&rsc_id))) {
		GLSV_NODE_LIST *list;
		rsc_id = rsc_info->rsc_id;
		TRACE("Resource Id - : %d  Resource Name - %.10s ", (uns32)rsc_info->rsc_id, rsc_info->lck_name.value);
		TRACE("Can Orphan - %d Mode - %d ", rsc_info->can_orphan, (uns32)rsc_info->orphan_lck_mode);
		list = rsc_info->node_list;
		TRACE("List of Nodes :");
		while (list != NULL) {
			TRACE("%d    ", m_NCS_NODE_ID_FROM_MDS_DEST(list->dest_id));
			list = list->next;
		}
	}
	ncshm_give_hdl(gl_gld_hdl);
	TRACE("************************************************** ");

}