コード例 #1
0
/******************************************************************************
  Name          : avnd_evt_ava_comp_val_req
 
  Description   : This routine creates a validation req msg and sends to AvD.
 
  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_ava_comp_val_req(AVND_CB *cb, AVND_EVT *evt)
{
	uns32 rc = NCSCC_RC_SUCCESS;
	AVND_DND_MSG_LIST *rec = 0;
	AVND_MSG msg;
	AVSV_AMF_API_INFO *api_info = &evt->info.ava.msg->info.api_info;
	AVSV_AMF_COMP_REG_PARAM *reg = &api_info->param.reg;

	TRACE_ENTER2("%s,Type=%u,Hdl=%llx",
			      reg->comp_name.value, api_info->type, reg->hdl);

	memset(&msg, 0, sizeof(AVND_MSG));

	/* populate the msg */
	if (0 != (msg.info.avd = calloc(1, sizeof(AVSV_DND_MSG)))) {
		msg.type = AVND_MSG_AVD;
		msg.info.avd->msg_type = AVSV_N2D_COMP_VALIDATION_MSG;
		msg.info.avd->msg_info.n2d_comp_valid_info.msg_id = ++(cb->snd_msg_id);
		msg.info.avd->msg_info.n2d_comp_valid_info.node_id = cb->node_info.nodeId;
		msg.info.avd->msg_info.n2d_comp_valid_info.comp_name =
		    evt->info.ava.msg->info.api_info.param.reg.comp_name;

		/* add the record to the AvD msg list */
		if ((0 != (rec = avnd_diq_rec_add(cb, &msg)))) {
			/* These parameters would not be encoded or decoded so, wouldn't be sent to AvD. */
			rec->msg.info.avd->msg_info.n2d_comp_valid_info.hdl = reg->hdl;
			rec->msg.info.avd->msg_info.n2d_comp_valid_info.proxy_comp_name = reg->proxy_comp_name;
			rec->msg.info.avd->msg_info.n2d_comp_valid_info.mds_dest = api_info->dest;
			rec->msg.info.avd->msg_info.n2d_comp_valid_info.mds_ctxt = evt->mds_ctxt;
			/* send the message */
			rc = avnd_diq_rec_send(cb, rec);

			if ((NCSCC_RC_SUCCESS != rc) && rec) {
				LOG_ER("avnd_diq_rec_send:failed:%s,Type:%u and Hdl%llx",
						    reg->comp_name.value, api_info->type, reg->hdl);
				/* pop & delete */
				m_AVND_DIQ_REC_FIND_POP(cb, rec);
				avnd_diq_rec_del(cb, rec);
			}
		} else {
			rc = NCSCC_RC_FAILURE;
			LOG_ER("avnd_diq_rec_add failed::%s,Type:%u and Hdl%llx",
						reg->comp_name.value, api_info->type, reg->hdl);
		}
	} else
		rc = NCSCC_RC_FAILURE;

	if (NCSCC_RC_FAILURE == rc) {
		LOG_ER("avnd_evt_ava_comp_val_req:%s,Type:%u and Hdl%llx",
						reg->comp_name.value, api_info->type, reg->hdl); 
	}
	/* free the contents of avnd message */
	avnd_msg_content_free(cb, &msg);

	return rc;

}
コード例 #2
0
/**************************************************************************
 Function: smfnd_amf_init

 Purpose:  Function which initializes SMFND with AMF.  

 Input:    None 

 Returns:  SA_AIS_OK    - everything is OK
           SA_AIS_ERR_* - failure

**************************************************************************/
SaAisErrorT smfnd_amf_init(smfnd_cb_t * cb)
{
	SaAmfCallbacksT amfCallbacks;
	SaVersionT amf_version;
	SaAisErrorT result;

	TRACE_ENTER();

	/* Initialize AMF callbacks */
	memset(&amfCallbacks, 0, sizeof(SaAmfCallbacksT));
	amfCallbacks.saAmfHealthcheckCallback = amf_health_chk_callback;
	amfCallbacks.saAmfCSISetCallback = amf_csi_set_callback;
	amfCallbacks.saAmfComponentTerminateCallback = amf_comp_terminate_callback;
	amfCallbacks.saAmfCSIRemoveCallback = amf_csi_rmv_callback;

	amf_version.releaseCode = 'B';
	amf_version.majorVersion = 0x01;
	amf_version.minorVersion = 0x01;

	/* Initialize the AMF library */
	result = saAmfInitialize(&cb->amf_hdl, &amfCallbacks, &amf_version);
	if (result != SA_AIS_OK) {
		LOG_ER("saAmfInitialize() FAILED: %u", result);
		goto done;
	}

	/* Obtain the AMF selection object to wait for AMF events */
	result = saAmfSelectionObjectGet(cb->amf_hdl, &cb->amfSelectionObject);
	if (result != SA_AIS_OK) {
		LOG_ER("saAmfSelectionObjectGet() FAILED: %u", result);
		goto done;
	}

	/* Get the component name */
	result = saAmfComponentNameGet(cb->amf_hdl, &cb->comp_name);
	if (result != SA_AIS_OK) {
		LOG_ER("saAmfComponentNameGet() FAILED: %u", result);
		goto done;
	}

	/* Register component with AMF */
	result = saAmfComponentRegister(cb->amf_hdl, &cb->comp_name, (SaNameT *) NULL);
	if (result != SA_AIS_OK) {
		LOG_ER("saAmfComponentRegister() FAILED");
		goto done;
	}

	/* Start AMF healthchecks */
	if ((result = amf_healthcheck_start(cb)) != SA_AIS_OK) {
		LOG_ER("amf_healthcheck_start() FAILED");
		goto done;
	}

 done:
	TRACE_LEAVE();
	return result;
}
コード例 #3
0
/**
 * Initialize smfnd
 * 
 * @return uns32
 */
static uns32 initialize_smfnd(void)
{
	uns32 rc;

	TRACE_ENTER();

	if (ncs_agents_startup() != NCSCC_RC_SUCCESS) {
		LOG_ER("ncs_agents_startup FAILED");
		rc = NCSCC_RC_FAILURE;
		goto done;
	}

	/* Initialize smfnd control block */
	if (smfnd_cb_init(smfnd_cb) != NCSCC_RC_SUCCESS) {
		TRACE("smfnd_cb_init FAILED");
		rc = NCSCC_RC_FAILURE;
		goto done;
	}

	/* Create the mailbox used for communication with SMFD/SMFA */
	if ((rc = m_NCS_IPC_CREATE(&smfnd_cb->mbx)) != NCSCC_RC_SUCCESS) {
		LOG_ER("m_NCS_IPC_CREATE FAILED %d", rc);
		goto done;
	}

	/* Attach mailbox to this thread */
	if ((rc = m_NCS_IPC_ATTACH(&smfnd_cb->mbx) != NCSCC_RC_SUCCESS)) {
		LOG_ER("m_NCS_IPC_ATTACH FAILED %d", rc);
		goto done;
	}

	/* Create a selection object for USR1 signal handling */
	if ((rc = ncs_sel_obj_create(&smfnd_cb->usr1_sel_obj)) != NCSCC_RC_SUCCESS) {
		LOG_ER("ncs_sel_obj_create failed");
		goto done;
	}

	/* Initialize mds communication */
	if ((rc = smfnd_mds_init(smfnd_cb)) != NCSCC_RC_SUCCESS) {
		TRACE("smfnd_mds_init FAILED %d", rc);
		return rc;
	}

	/* Check if AMF started */
	if (smfnd_cb->nid_started == 0) {
		/* Started by AMF, so let's init AMF */
		if ((rc = smfnd_amf_init(smfnd_cb)) != NCSCC_RC_SUCCESS) {
			LOG_ER("init amf failed");
			goto done;
		}
	}

 done:
	TRACE_LEAVE();
	return (rc);
}
コード例 #4
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;
}
コード例 #5
0
ファイル: rde_main.c プロジェクト: indonexia2004/opensaf-indo
/**
 * Initialize the RDE server.
 * 
 * @return int, 0=OK
 */
static int initialize_rde(void)
{
	RDE_RDA_CB *rde_rda_cb = &rde_cb->rde_rda_cb;
	int rc = NCSCC_RC_FAILURE;
	char *val;

	/* Determine how this process was started, by NID or AMF */
	if (getenv("SA_AMF_COMPONENT_NAME") == NULL)
		rde_cb->rde_amf_cb.nid_started = true;

	if ((val = getenv("RDE_DISCOVER_PEER_TIMEOUT")) != NULL)
		discover_peer_timeout = strtoul(val, NULL, 0);

	TRACE("discover_peer_timeout=%d", discover_peer_timeout);

	if ((rc = ncs_core_agents_startup()) != NCSCC_RC_SUCCESS) {
		LOG_ER("ncs_core_agents_startup FAILED");
		goto init_failed;
	}

	if (rde_cb->rde_amf_cb.nid_started &&
		(rc = ncs_sel_obj_create(&usr1_sel_obj)) != NCSCC_RC_SUCCESS) {
		LOG_ER("ncs_sel_obj_create FAILED");
		goto init_failed;
	}

	if ((rc = ncs_ipc_create(&rde_cb->mbx)) != NCSCC_RC_SUCCESS) {
		LOG_ER("ncs_ipc_create FAILED");
		goto init_failed;
	}

	if ((rc = ncs_ipc_attach(&rde_cb->mbx)) != NCSCC_RC_SUCCESS) {
		LOG_ER("ncs_ipc_attach FAILED");
		goto init_failed;
	}

	rde_my_node_id = ncs_get_node_id();

	if ((rc = rde_rda_open(RDE_RDA_SOCK_NAME, rde_rda_cb)) != NCSCC_RC_SUCCESS)
		goto init_failed;

	if (rde_cb->rde_amf_cb.nid_started &&
		signal(SIGUSR1, sigusr1_handler) == SIG_ERR) {
		LOG_ER("signal USR1 FAILED: %s", strerror(errno));
		goto init_failed;
	}

	if (rde_mds_register(rde_cb) != NCSCC_RC_SUCCESS)
		goto init_failed;

	rc = NCSCC_RC_SUCCESS;

 init_failed:
	return rc;
}
コード例 #6
0
ファイル: plms_amf.c プロジェクト: helioloureiro/opensaf-fork
/****************************************************************************
 * Name          : plms_amf_init
 *
 * Description   : PLMS initializes AMF for invoking process and registers 
 *                 the various callback functions.
 *
 * Arguments     : PLMS_CB - PLMS control block pointer.
 *
 * Return Values : NCSCC_RC_SUCCESS/Error Code.
 *
 * Notes         : None.
 *****************************************************************************/
SaUint32T plms_amf_init()
{
	PLMS_CB * cb = plms_cb;
	SaAmfCallbacksT amfCallbacks;
	SaVersionT amf_version;
	uint32_t rc = NCSCC_RC_SUCCESS;

	TRACE_ENTER();

	if (cb->nid_started &&
		amf_comp_name_get_set_from_file("PLMD_COMP_NAME_FILE", &cb->comp_name) != NCSCC_RC_SUCCESS)
                goto done;

	/* Initialize amf callbacks */
	memset(&amfCallbacks, 0, sizeof(SaAmfCallbacksT));

	amfCallbacks.saAmfHealthcheckCallback = plms_amf_health_chk_callback;
	amfCallbacks.saAmfCSISetCallback = plms_amf_CSI_set_callback;
	amfCallbacks.saAmfComponentTerminateCallback = plms_amf_comp_terminate_callback;
	amfCallbacks.saAmfCSIRemoveCallback = plms_amf_csi_rmv_callback;

	m_PLMS_GET_AMF_VER(amf_version);

	/*Initialize the amf library */

	rc = saAmfInitialize(&cb->amf_hdl, &amfCallbacks, &amf_version);

	if (rc != SA_AIS_OK) {
		LOG_ER("  plms_amf_init: saAmfInitialize() AMF initialization FAILED\n");
		goto done;
	}
	LOG_IN("  plms_amf_init: saAmfInitialize() AMF initialization SUCCESS\n");

	/* Obtain the amf selection object to wait for amf events */
	if (SA_AIS_OK != (rc = saAmfSelectionObjectGet(cb->amf_hdl, &cb->amf_sel_obj))) {
		LOG_ER("saAmfSelectionObjectGet() FAILED\n");
		goto done;
	}
	LOG_IN("saAmfSelectionObjectGet() SUCCESS\n");

	/* get the component name */

	rc = saAmfComponentNameGet(cb->amf_hdl, &cb->comp_name);
	if (rc != SA_AIS_OK) {
		LOG_ER("  plmss_amf_init: saAmfComponentNameGet() FAILED\n");
		goto done ;
	}

	rc = NCSCC_RC_SUCCESS;
done:
        TRACE_LEAVE2("%u, %s", rc, cb->comp_name.value);
        return rc;

}	/*End plms_amf_init */
コード例 #7
0
ファイル: lgs_amf.c プロジェクト: helioloureiro/opensaf-fork
/****************************************************************************
 * Name          : amf_active_state_handler
 *
 * Description   : This function is called upon receiving an active state
 *                 assignment from AMF.
 *
 * Arguments     : invocation - Designates a particular invocation.
 *                 cb         - A pointer to the LGS control block. 
 *
 * Return Values : None
 *
 * Notes         : None 
 *****************************************************************************/
static SaAisErrorT amf_active_state_handler(lgs_cb_t *cb, SaInvocationT invocation)
{
	log_stream_t *stream;
	SaAisErrorT error = SA_AIS_OK;

	TRACE_ENTER2("HA ACTIVE request");

	if (cb->ha_state == SA_AMF_HA_ACTIVE) {
		/* State change was already processed in RDA callback */
		goto done;
	}

	/* switch over, become implementer
	 * If a configuration object exists then we are an object applier that has
	 * to be cleared before we can become an object implementer.
	 */
	immutilWrapperProfile.nTries = 250; /* LOG will be blocked until IMM responds */
	immutilWrapperProfile.errorsAreFatal = 0;
	if ((error = immutil_saImmOiImplementerSet(lgs_cb->immOiHandle, "safLogService"))
			!= SA_AIS_OK) {
		LOG_ER("saImmOiClassImplementerSet (safLogService) failed: %d", error);
		goto done;
	}
	if ((error = immutil_saImmOiClassImplementerSet(lgs_cb->immOiHandle,
			"SaLogStreamConfig")) != SA_AIS_OK) {
		LOG_ER("saImmOiClassImplementerSet (SaLogStreamConfig) failed: %d", error);
		goto done;
	}
	/* Do this only if the class exists */
	if (*(bool*) lgs_imm_logconf_get(LGS_IMM_LOG_OPENSAFLOGCONFIG_CLASS_EXIST, NULL)) {
		if ((error = immutil_saImmOiClassImplementerSet(cb->immOiHandle, "OpenSafLogConfig"))
				!= SA_AIS_OK) {
			LOG_ER("saImmOiClassImplementerSet (OpenSafLogConfig) failed: %d", error);
			goto done;
		}
	}

	/* check existing streams */
	stream = log_stream_getnext_by_name(NULL);
	if (!stream)
		LOG_ER("No streams exist!");
	while (stream != NULL) {
		*stream->p_fd = -1; /* First Initialize fd */
		stream = log_stream_getnext_by_name(stream->name);
	}

 done:
	immutilWrapperProfile.nTries = 20; /* Reset retry time to more normal value. */
	immutilWrapperProfile.errorsAreFatal = 1;
	/* Update role independent of stream processing */
	lgs_cb->mds_role = V_DEST_RL_ACTIVE;
	TRACE_LEAVE();
	return error;
}
コード例 #8
0
ファイル: rde_amf.c プロジェクト: kenzaburo/OpenSaf-FrameWork
uns32 rde_amf_init(RDE_AMF_CB *rde_amf_cb)
{
	uns32 rc = NCSCC_RC_SUCCESS;
	SaAisErrorT amf_error = SA_AIS_OK;
	SaNameT sname;
	SaAmfCallbacksT amfCallbacks;
	SaVersionT amf_version;

	TRACE_ENTER();

	if (amf_comp_name_get_set_from_file("RDE_COMP_NAME_FILE", &sname) != NCSCC_RC_SUCCESS)
		return NCSCC_RC_FAILURE;

	amfCallbacks.saAmfHealthcheckCallback = rde_saf_health_chk_callback;
	amfCallbacks.saAmfCSISetCallback = rde_saf_CSI_set_callback;
	amfCallbacks.saAmfCSIRemoveCallback = rde_saf_CSI_rem_callback;
	amfCallbacks.saAmfComponentTerminateCallback = rde_saf_comp_terminate_callback;

	m_RDE_GET_AMF_VER(amf_version);

	amf_error = saAmfInitialize(&rde_amf_cb->amf_hdl, &amfCallbacks, &amf_version);
	if (amf_error != SA_AIS_OK) {
		LOG_ER("saAmfInitialize FAILED %u", amf_error);
		return NCSCC_RC_FAILURE;
	}

	memset(&sname, 0, sizeof(sname));
	amf_error = saAmfComponentNameGet(rde_amf_cb->amf_hdl, &sname);
	if (amf_error != SA_AIS_OK) {
		LOG_ER("saAmfComponentNameGet FAILED %u", amf_error);
		return NCSCC_RC_FAILURE;
	}

	strcpy((char*)rde_amf_cb->comp_name, (char*)sname.value);

	amf_error = saAmfSelectionObjectGet(rde_amf_cb->amf_hdl, &rde_amf_cb->amf_fd);
	if (amf_error != SA_AIS_OK) {
		LOG_ER("saAmfSelectionObjectGet FAILED %u", amf_error);
		return NCSCC_RC_FAILURE;
	}

	amf_error = saAmfComponentRegister(rde_amf_cb->amf_hdl, &sname, (SaNameT *)NULL);
	if (amf_error != SA_AIS_OK) {
		LOG_ER("saAmfComponentRegister FAILED %u", amf_error);
		return NCSCC_RC_FAILURE;
	}

	rc = rde_amf_healthcheck_start(rde_amf_cb);
	if (rc != NCSCC_RC_SUCCESS)
		return NCSCC_RC_FAILURE;

	TRACE_LEAVE2("AMF Initialization SUCCESS......");
	return(rc);
}
コード例 #9
0
ファイル: gld_evt.c プロジェクト: helioloureiro/opensaf-fork
/*****************************************************************************
  PROCEDURE NAME : gld_process_tmr_node_restart_wait_timeout

  DESCRIPTION    :

  ARGUMENTS      :gld_cb      - ptr to the GLD control block
                  evt          - ptr to the event.

  RETURNS        :NCSCC_RC_FAILURE/NCSCC_RC_SUCCESS

  NOTES         : None
*****************************************************************************/
static uint32_t gld_process_tmr_node_restart_wait_timeout(GLSV_GLD_EVT *evt)
{
	GLSV_GLD_CB *gld_cb = evt->gld_cb;
	GLSV_GLD_GLND_DETAILS *node_details;
	GLSV_GLD_GLND_RSC_REF *glnd_rsc;
	SaLckResourceIdT rsc_id;
	uint32_t node_id;

	node_id = m_NCS_NODE_ID_FROM_MDS_DEST(evt->info.tmr.mdest_id);
	TRACE_ENTER2("Node restart wait timer expired: node_id %u", node_id);

	if ((node_details =
	     (GLSV_GLD_GLND_DETAILS *)ncs_patricia_tree_get(&gld_cb->glnd_details, (uint8_t *)&node_id)) == NULL) {
		LOG_ER("Evenr from unknown glnd: node_id %u", node_id);
		return NCSCC_RC_FAILURE;
	}

	if (gld_cb->ha_state == SA_AMF_HA_ACTIVE) {

		/* checkpoint node_details */
		glsv_gld_a2s_ckpt_node_details(gld_cb, node_details->dest_id, GLSV_GLD_EVT_GLND_DOWN);

		/* If this node is non master for any resource, then send node status to the master */
		gld_process_send_non_master_status(gld_cb, node_details, GLND_DOWN_STATE);

		/* Remove the reference to each of the resource referred by this node */
		glnd_rsc = (GLSV_GLD_GLND_RSC_REF *)ncs_patricia_tree_getnext(&node_details->rsc_info_tree, (uint8_t *)0);
		if (glnd_rsc) {
			rsc_id = glnd_rsc->rsc_id;
			while (glnd_rsc) {
				gld_rsc_rmv_node_ref(gld_cb, glnd_rsc->rsc_info, glnd_rsc, node_details,
						     glnd_rsc->rsc_info->can_orphan);
				glnd_rsc =
				    (GLSV_GLD_GLND_RSC_REF *)ncs_patricia_tree_getnext(&node_details->rsc_info_tree,
										       (uint8_t *)&rsc_id);
				if (glnd_rsc)
					rsc_id = glnd_rsc->rsc_id;
			}
		}

		/* Now delete this node details node */
		if (ncs_patricia_tree_del(&gld_cb->glnd_details, (NCS_PATRICIA_NODE *)node_details) != NCSCC_RC_SUCCESS) {
			LOG_ER("Patricia tree del failed: node_id %u",
					   node_details->node_id);
		} else {
			m_MMGR_FREE_GLSV_GLD_GLND_DETAILS(node_details);
			TRACE("Node getting removed on active: node_id %u", node_id);
		}
	} else {
		node_details->status = GLND_DOWN_STATE;
	}
	return NCSCC_RC_SUCCESS;
}
コード例 #10
0
ファイル: gld_evt.c プロジェクト: helioloureiro/opensaf-fork
/****************************************************************************
 * Name          : gld_rsc_close
 *
 * Description   : This is the function is invoked when a rsc_close event is
 *                 is sent from a GLND. 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     : evt  - Event structure
 *
 * Return Values : NCSCC_RC_SUCCESS/ NCSCC_RC_FAILURE
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t gld_rsc_close(GLSV_GLD_EVT *evt)
{
	GLSV_GLD_CB *gld_cb = evt->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_SUCCESS;
	TRACE_ENTER2("component name %s", gld_cb->comp_name.value);

	node_id = m_NCS_NODE_ID_FROM_MDS_DEST(evt->fr_dest_id);

	if ((evt == GLSV_GLD_EVT_NULL) || (gld_cb == NULL)){
		rc = NCSCC_RC_FAILURE;
		goto end;
	}

	orphan_flag = 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("Event from unknown glnd: node_id %u ", node_id);
		rc = NCSCC_RC_FAILURE;
		goto end;
	}

	glnd_rsc = (GLSV_GLD_GLND_RSC_REF *)ncs_patricia_tree_get(&node_details->rsc_info_tree,
								  (uint8_t *)&evt->info.rsc_details.rsc_id);
	if ((glnd_rsc == NULL) || (glnd_rsc->rsc_info == NULL)) {
		LOG_ER("Rsc operation for unopened rsc: rsc_id %u node_id %u ",
				   evt->info.rsc_details.rsc_id, node_details->node_id);
		goto end;
	}

	TRACE("EVT Processing rsc close rsc_id %u node_id %u", glnd_rsc->rsc_info->rsc_id,
		      node_details->node_id);

	if (glnd_rsc->rsc_info->saf_rsc_no_of_users > 0)
		glnd_rsc->rsc_info->saf_rsc_no_of_users = glnd_rsc->rsc_info->saf_rsc_no_of_users - 1;

	/*Checkkpoint resource close event */
	glsv_gld_a2s_ckpt_rsc_details(gld_cb, evt->evt_type, evt->info.rsc_details, node_details->dest_id,
				      evt->info.rsc_details.lcl_ref_cnt);

	if (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);
 end:	
	TRACE_LEAVE2("Return value %u", rc);
	return rc;
}
コード例 #11
0
ファイル: plms_hrb.c プロジェクト: indonexia2004/opensaf-indo
/***********************************************************************
* Name          : plms_hrb_initialize
*
* Description   : This function initializes the HRB control block
*                 and creates plms_hrb thread, It registers to MDS  
*		  to receive requests from PLMS
*
* Arguments     : 
*
* Return Values : NCSCC_RC_SUCCESS
*		  NCSCC_RC_FAILURE
***********************************************************************/
SaUint32T plms_hrb_initialize()
{
	PLMS_HRB_CB      *cb =  hrb_cb;
	pthread_t        thread_id;
	pthread_attr_t   attr;
	struct sched_param thread_priority;
	SaUint32T        policy;
	SaUint32T	 rc;

	TRACE_ENTER();

	/* create the mail box and attach it */
	if ((rc = m_NCS_IPC_CREATE(&cb->mbx)) != NCSCC_RC_SUCCESS){
		LOG_ER("error creating mail box err val:%d",rc);
		return NCSCC_RC_FAILURE;
	}

	if ((rc = m_NCS_IPC_ATTACH(&cb->mbx)) != NCSCC_RC_SUCCESS){
		LOG_ER("error attaching mail box err val:%d",rc);
		return NCSCC_RC_FAILURE;
	}

	/* Initialize with the MDS */
	if(hrb_mds_initialize() != NCSCC_RC_SUCCESS){
		LOG_ER("HRB: mds initialization failed");
		return NCSCC_RC_FAILURE;
	}

	/* Initialize thread attribute */
	pthread_attr_init(&attr);
	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

	pthread_attr_setstacksize(&attr, PLMS_HRB_STACKSIZE);

	/* Create PLMS_HRB thread */
	rc = pthread_create(&thread_id, &attr, plms_hrb, NULL);
	if(rc){
		LOG_ER("pthread_create FAILED ret code:%d error:%s",
				rc,strerror(errno));
		return NCSCC_RC_FAILURE;
	}
	
	/*scheduling parameters of the thread */
        memset(&thread_priority, 0, sizeof(thread_priority));
	thread_priority.sched_priority = PLMS_HRB_TASK_PRIORITY;
	policy = SCHED_OTHER;
	pthread_setschedparam(thread_id, policy, &thread_priority);

	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
コード例 #12
0
ファイル: plma_mds.c プロジェクト: helioloureiro/opensaf-fork
/***********************************************************************//**
* @brief	This routine registers the PLMA with MDS.
*
* @return	NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
***************************************************************************/
uint32_t plma_mds_register()
{
        uint32_t rc = NCSCC_RC_SUCCESS;
        NCSMDS_INFO svc_info;
        MDS_SVC_ID svc_id[1] = { NCSMDS_SVC_ID_PLMS};
	PLMA_CB *plma_cb = plma_ctrlblk;
	TRACE_ENTER();

        /* STEP 1: the MDS handle for PLMA*/
        rc = plma_mds_get_handle();
        if (NCSCC_RC_SUCCESS != rc) {
                LOG_ER("PLMA - mds get handle failed");
                return rc;
        }
        
        /* STEP 2 : Install with MDS with service ID NCSMDS_SVC_ID_PLMA. */
	memset(&svc_info, 0, sizeof(NCSMDS_INFO));

        svc_info.i_mds_hdl = plma_cb->mds_hdl;
        svc_info.i_svc_id = NCSMDS_SVC_ID_PLMA;
        svc_info.i_op = MDS_INSTALL;

        svc_info.info.svc_install.i_yr_svc_hdl = 0; 
        svc_info.info.svc_install.i_install_scope = NCSMDS_SCOPE_NONE;  /*node specific */
        svc_info.info.svc_install.i_svc_cb = plma_mds_callback; /* callback */
        svc_info.info.svc_install.i_mds_q_ownership = false;
	/***************************FIXME : MDS svc private sub part ver no?.**/
        svc_info.info.svc_install.i_mds_svc_pvt_ver = PLMA_MDS_PVT_SUBPART_VERSION;

        if (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) {
                LOG_ER("PLMA - MDS Install Failed");
                return NCSCC_RC_FAILURE;
        }

	/* STEP 3 : Subscribe to PLMS up/down events */
        memset(&svc_info, 0, sizeof(NCSMDS_INFO));
        svc_info.i_mds_hdl = plma_cb->mds_hdl;
        svc_info.i_svc_id = NCSMDS_SVC_ID_PLMA;
        svc_info.i_op = MDS_SUBSCRIBE;
        svc_info.info.svc_subscribe.i_num_svcs = 1;
        svc_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_NONE;
        svc_info.info.svc_subscribe.i_svc_ids = svc_id;
        if (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) {
                LOG_ER("PLMA - MDS Subscribe for PLMS up/down Failed");
                plma_mds_unregister();
                return NCSCC_RC_FAILURE;
        }
	TRACE_LEAVE();
	return rc;

}
コード例 #13
0
/*************************************************************************** 
@brief		: saSmfDispatch 
@param[in]	: smfHandle - Handle returned by successful intialize. 
@param[in]	: dispatchFlags - Dispatch flag. 
@return		: SA_AIS_OK if successful otherwise appropiate err code.
*****************************************************************************/
SaAisErrorT saSmfDispatch(
		SaSmfHandleT smfHandle,
		SaDispatchFlagsT dispatchFlags)
{	
	
	SMFA_CB *cb = &_smfa_cb;
	SMFA_CLIENT_INFO *client_info;
	SaAisErrorT rc = SA_AIS_OK;

	TRACE_ENTER2("SMFA: Handle %llu.",smfHandle);
	if (cb->is_finalized){
		LOG_ER("SMFA: Already finalized, Bad handle: %llu.",smfHandle);
		TRACE_LEAVE();
		return SA_AIS_ERR_BAD_HANDLE;
	}
	
	/* To protect the finalize during dispatch.*/
	if (NCSCC_RC_SUCCESS != m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_READ)){
		LOG_ER("SMFA: Cb lock acquire FAILED.");
		TRACE_LEAVE();
		return SA_AIS_ERR_NO_RESOURCES;
	}
	
	/* Get the client info structure for the handle.*/
	client_info = smfa_client_info_get(smfHandle);
	if (NULL == client_info){
		LOG_ER("SMFA: Bad handle.");
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_READ);
		TRACE_LEAVE();
		return SA_AIS_ERR_BAD_HANDLE;
	}
	m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_READ);

	/* Validate the flags and invoke corresponding functions.*/
	switch(dispatchFlags){
		case SA_DISPATCH_ONE:
			rc = smfa_dispatch_cbk_one(client_info);
			break;
		case SA_DISPATCH_ALL:
			rc = smfa_dispatch_cbk_all(client_info);
			break;
		case SA_DISPATCH_BLOCKING:
			rc = smfa_dispatch_cbk_block(client_info);
			break;
		default:
			LOG_ER("SMFA: Invalid flag: %d",dispatchFlags);
			rc = SA_AIS_ERR_INVALID_PARAM;
	}
	TRACE_LEAVE();
	return rc;
}
コード例 #14
0
/**
 *  @Brief: Check SaNameT is a valid formation
 *
 */
bool ntfsv_sanamet_is_valid(const SaNameT* pName)
{
	if (!osaf_is_extended_name_valid(pName)) {
		LOG_ER("Environment variable SA_ENABLE_EXTENDED_NAMES "
			"is not set, or not using extended name api");
		return false;
	}
	if (osaf_extended_name_length(pName) > kOsafMaxDnLength) {
		LOG_ER("Exceeding maximum of extended name length(%u)"
			,kOsafMaxDnLength);
		return false;
	}
	return true;
}
コード例 #15
0
/*************************************************************************** 
@brief		: saSmfFinalize 
@param[in]	: smfHandle - Handle returned by successful intialize. 
@return		: SA_AIS_OK if successful otherwise appropiate err code.
*****************************************************************************/
SaAisErrorT saSmfFinalize(SaSmfHandleT smfHandle)
{
	SMFA_CB *cb = &_smfa_cb;
	SMFA_CLIENT_INFO *client_info;
	
	TRACE_ENTER2("Handle: %llu",smfHandle);
	if (cb->is_finalized){
		LOG_ER("SMFA: Already finalized. Bad handle %llu.",smfHandle);
		TRACE_LEAVE();
		return SA_AIS_ERR_BAD_HANDLE;
	}

	if (NCSCC_RC_SUCCESS != m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_WRITE)){
		LOG_ER("SMFA: Cb lock acquire FAILED.");
		TRACE_LEAVE();
		return SA_AIS_ERR_NO_RESOURCES;
	}
	
	/* Get the client info structure for the handle.*/
	client_info = smfa_client_info_get(smfHandle);
	if (NULL == client_info){
		LOG_ER("SMFA: Could not retrieve client info, Bad handle %llu.",smfHandle);
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
		TRACE_LEAVE();
		return SA_AIS_ERR_BAD_HANDLE;
	}
	/* Free all the scope info registered for this client.*/
	smfa_client_info_clean(client_info);
	
	/* Release the MBX.*/
	m_NCS_IPC_DETACH(&client_info->cbk_mbx,smfa_client_mbx_clnup,client_info);
	m_NCS_IPC_RELEASE(&client_info->cbk_mbx,NULL);

	/* Clear the list cb->cbk_list for this handle.*/
	smfa_cbk_list_cleanup(smfHandle);

	/* Remove the client from the cb.*/
	smfa_client_info_rmv(client_info->client_hdl);
	
	m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
	
	/* If last client, then destroy the agent CB.*/
	if (NCSCC_RC_SUCCESS != smfa_finalize()){
		TRACE_LEAVE();
		return SA_AIS_ERR_LIBRARY;
	}

	TRACE_LEAVE();
	return SA_AIS_OK;
}
コード例 #16
0
ファイル: rde_mds.c プロジェクト: kenzaburo/OpenSaf-FrameWork
uns32 rde_mds_register(RDE_CONTROL_BLOCK *cb)
{
	NCSADA_INFO ada_info;
	NCSMDS_INFO svc_info;
	MDS_SVC_ID svc_id[1] = { NCSMDS_SVC_ID_RDE };
	MDS_DEST mds_adest;

	TRACE_ENTER();

	ada_info.req = NCSADA_GET_HDLS;
	if (ncsada_api(&ada_info) != NCSCC_RC_SUCCESS) {
		LOG_ER("%s: NCSADA_GET_HDLS Failed", __FUNCTION__);
		return NCSCC_RC_FAILURE;
	}

	mds_hdl = ada_info.info.adest_get_hdls.o_mds_pwe1_hdl;
	mds_adest = ada_info.info.adest_get_hdls.o_adest;

	svc_info.i_mds_hdl = mds_hdl;
	svc_info.i_svc_id = NCSMDS_SVC_ID_RDE;
	svc_info.i_op = MDS_INSTALL;

	svc_info.info.svc_install.i_yr_svc_hdl = 0;
	svc_info.info.svc_install.i_install_scope = NCSMDS_SCOPE_NONE;	/*node specific */
	svc_info.info.svc_install.i_svc_cb = mds_callback;	/* callback */
	svc_info.info.svc_install.i_mds_q_ownership = FALSE;
	svc_info.info.svc_install.i_mds_svc_pvt_ver = RDE_MDS_PVT_SUBPART_VERSION;

	if (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) {
		LOG_ER("%s: MDS Install Failed", __FUNCTION__);
		return NCSCC_RC_FAILURE;
	}

	memset(&svc_info, 0, sizeof(NCSMDS_INFO));
	svc_info.i_mds_hdl = mds_hdl;
	svc_info.i_svc_id = NCSMDS_SVC_ID_RDE;
	svc_info.i_op = MDS_RED_SUBSCRIBE;
	svc_info.info.svc_subscribe.i_num_svcs = 1;
	svc_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_NONE;
	svc_info.info.svc_subscribe.i_svc_ids = svc_id;

	if (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) {
		LOG_ER("MDS Subscribe for redundancy Failed");
		return NCSCC_RC_FAILURE;
	}

	TRACE_LEAVE2("NodeId:%x, mds_adest:%llx", ncs_get_node_id(), mds_adest);

	return NCSCC_RC_SUCCESS;
}
コード例 #17
0
/******************************************************************************
  Name          : avnd_internode_comp_del
 
  Description   : This routine deletes an internode component from internode_avail_comp_db.
 
  Arguments     : ptree  - ptr to the patricia tree of data base.
                  name - ptr to the component name.
                        
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
uns32 avnd_internode_comp_del(AVND_CB *cb, NCS_PATRICIA_TREE *ptree, SaNameT *name)
{
	AVND_COMP *comp = 0;
	uns32 rc = NCSCC_RC_SUCCESS;
	AVND_COMP_CBK *cbk_rec = NULL, *temp_cbk_ptr = NULL;

	/* get the comp */
	comp = m_AVND_COMPDB_REC_GET(*ptree, *name);
	if (!comp) {
		rc = AVND_ERR_NO_COMP;
		LOG_ER("internode_comp_del failed. Rec doesn't exist :%s", name->value);
		goto err;
	}
	TRACE("avnd_internode_comp_del:%s: nodeid:%u, comp_type:%u",
			      comp->name.value, comp->node_id, comp->comp_type);

/*  Delete the callbacks if any. */
	cbk_rec = comp->cbk_list;
	while (cbk_rec) {
		temp_cbk_ptr = cbk_rec->next;
		m_AVND_SEND_CKPT_UPDT_ASYNC_RMV(cb, cbk_rec, AVND_CKPT_COMP_CBK_REC);
		avnd_comp_cbq_rec_del(cb, comp, cbk_rec);
		cbk_rec = temp_cbk_ptr;
	}

	/* 
	 * Remove from the patricia tree.
	 */
	rc = ncs_patricia_tree_del(ptree, &comp->tree_node);
	if (NCSCC_RC_SUCCESS != rc) {
		rc = AVND_ERR_TREE;
		goto err;
	}

	/* free the memory */
	if (comp)
		avnd_comp_delete(comp);
	return rc;

 err:

	/* free the memory */
	if (comp)
		avnd_comp_delete(comp);

	LOG_ER("internode_comp_del failed: %s ,rc=%u", name->value, rc);

	return rc;

}
コード例 #18
0
static SaAisErrorT svctype_ccb_completed_cb(CcbUtilOperationData_t *opdata)
{
	SaAisErrorT rc = SA_AIS_ERR_BAD_OPERATION;
	AVD_SVC_TYPE *svc_type;
	AVD_SI *si;
	SaBoolT si_exist = SA_FALSE;
	CcbUtilOperationData_t *t_opData;

	TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, opdata->objectName.value);

	switch (opdata->operationType) {
	case CCBUTIL_CREATE:
		if (is_config_valid(&opdata->objectName, opdata->param.create.attrValues, opdata))
		    rc = SA_AIS_OK;
		break;
	case CCBUTIL_MODIFY:
		LOG_ER("Modification of SaAmfSvcType not supported");
		break;
	case CCBUTIL_DELETE:
		svc_type = avd_svctype_get(&opdata->objectName);
		if (NULL != svc_type->list_of_si) {
			/* check whether there exists a delete operation for
			 * each of the SI in the svc_type list in the current CCB
			 */
			si = svc_type->list_of_si;
			while (si != NULL) {
				t_opData = ccbutil_getCcbOpDataByDN(opdata->ccbId, &si->name);
				if ((t_opData == NULL) || (t_opData->operationType != CCBUTIL_DELETE)) {
					si_exist = SA_TRUE;
					break;
				}
				si = si->si_list_svc_type_next;
			}
			if (si_exist == SA_TRUE) {
				LOG_ER("SaAmfSvcType '%s' is in use",svc_type->name.value);
				goto done;
			}
		}
		opdata->userData = svc_type;
		rc = SA_AIS_OK;
		break;
	default:
		assert(0);
		break;
	}
done:
	TRACE_LEAVE2("%u", rc);
	return rc;
}
コード例 #19
0
/**
 * Handle a CCB completed event for SaAmfCSType
 * @param opdata
 * 
 * @return SaAisErrorT
 */
static SaAisErrorT cstype_ccb_completed_hdlr(CcbUtilOperationData_t *opdata)
{
	SaAisErrorT rc = SA_AIS_ERR_BAD_OPERATION;
	avd_cstype_t *cst;
	AVD_CSI *csi; 
	SaBoolT csi_exist = SA_FALSE;
	CcbUtilOperationData_t *t_opData;

	TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, opdata->objectName.value);

	switch (opdata->operationType) {
	case CCBUTIL_CREATE:
		if (is_config_valid(&opdata->objectName))
			rc = SA_AIS_OK;
		break;
	case CCBUTIL_MODIFY:
		LOG_ER("Modification of SaAmfCSType not supported");
		break;
	case CCBUTIL_DELETE:
		cst = avd_cstype_get(&opdata->objectName);
		if (cst->list_of_csi != NULL) {
			/* check whether there exists a delete operation for 
			 * each of the CSI in the cs_type list in the current CCB 
			 */                      
			csi = cst->list_of_csi;
			while (csi != NULL) {  
				t_opData = ccbutil_getCcbOpDataByDN(opdata->ccbId, &csi->name);
				if ((t_opData == NULL) || (t_opData->operationType != CCBUTIL_DELETE)) {
					csi_exist = SA_TRUE;   
					break;                  
				}                       
				csi = csi->csi_list_cs_type_next;
			}                       
			if (csi_exist == SA_TRUE) {
				LOG_ER("SaAmfCSType '%s' is in use", cst->name.value);
				goto done;
			}
		}
		opdata->userData = cst;	/* Save for later use in apply */
		rc = SA_AIS_OK;
		break;
	default:
		assert(0);
		break;
	}

done:
	return rc;
}
コード例 #20
0
/**
 * Function to process the incoming connection request
 *
 *
 * @return NCSCC_RC_SUCCESS
 * @return NCSCC_RC_FAILURE
 *
 */
static uint32_t dtm_intranode_process_incoming_conn(void)
{
	 int flags;
	/* Accept processing */
	int accept_fd = 0,  retry_count = 0, size = DTM_INTRANODE_SOCK_SIZE;
	socklen_t len = sizeof(struct sockaddr_un);
	struct sockaddr_un cli_addr;
	/* Accept should be non_block */
	TRACE_ENTER();
	accept_fd = accept(dtm_intranode_cb->server_sockfd, (struct sockaddr *)&cli_addr, &len);

	/* Error Checking */
	if (accept_fd < 0) {
		LOG_ER("DTM: Connection accept fail");
		return NCSCC_RC_FAILURE;
	}

tryagain:
	/*Make the socket Non-Blocking for accepting */
	if ((flags = fcntl(accept_fd, F_GETFL, NULL)) < 0) {
                LOG_ER("DTM :fcntl(F_SETFL, O_NONBLOCK) err :%s ", strerror(errno));
                return false;
        }
	flags |= O_NONBLOCK;	
	if (fcntl(accept_fd, F_SETFL, flags) < 0) {
		LOG_ER("DTM: accept_fd Non-Blocking hasnt been Set");
		retry_count++;
		/* Non-Blocking Options hasnt been set */
		if (retry_count > 3) {
			osafassert(0);
		} else {
			goto tryagain;
		}
	}
	if (setsockopt(accept_fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)) != 0) {
		LOG_ER("DTM: Unable to set the SO_RCVBUF ");
		close(accept_fd);
		return NCSCC_RC_FAILURE;
	}
	if (setsockopt(accept_fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) != 0) {
		LOG_ER("DTM: Unable to set the SO_SNDBUF ");
		close(accept_fd);
		return NCSCC_RC_FAILURE;
	}
	dtm_intranode_add_poll_fdlist(accept_fd, POLLIN);
	dtm_intranode_create_pid_info(accept_fd);
	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
コード例 #21
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;
}
コード例 #22
0
ファイル: smfa_mds.c プロジェクト: helioloureiro/opensaf-fork
/*************************************************************************** 
@brief		: Register with MDS and Subscribe to SMFND svc evts.
@return		: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
*****************************************************************************/
uint32_t smfa_mds_register()
{
	NCSADA_INFO arg;
	NCSMDS_INFO svc_info;
	MDS_SVC_ID svc_id[1] = { NCSMDS_SVC_ID_SMFND };
	SMFA_CB *cb = &_smfa_cb;
	
	/* Get MDS handle.*/		
	memset(&arg, 0, sizeof(NCSADA_INFO));
	arg.req = NCSADA_GET_HDLS;
	if (NCSCC_RC_SUCCESS != ncsada_api(&arg)){
		LOG_ER("SMFA: MDS get handle FAILED.");
		return NCSCC_RC_FAILURE;
	}
	cb->smfa_mds_hdl = arg.info.adest_get_hdls.o_mds_pwe1_hdl;

	/* Install with MDS. */ 
	memset(&svc_info, 0, sizeof(NCSMDS_INFO));
	svc_info.i_mds_hdl = cb->smfa_mds_hdl;
	svc_info.i_svc_id = NCSMDS_SVC_ID_SMFA;
	svc_info.i_op = MDS_INSTALL;

	svc_info.info.svc_install.i_yr_svc_hdl = 0;
	svc_info.info.svc_install.i_install_scope = NCSMDS_SCOPE_INTRANODE;
	svc_info.info.svc_install.i_svc_cb = smfa_mds_callback;
	svc_info.info.svc_install.i_mds_q_ownership = false;
	if (NCSCC_RC_SUCCESS != ncsmds_api(&svc_info)){
		LOG_ER("SMFA: MDS Install FAILED.");
		return NCSCC_RC_FAILURE;
	}

	/* Subscribe for SMFND UP/DOWN evetns.*/
	memset(&svc_info, 0, sizeof(NCSMDS_INFO));
	svc_info.i_mds_hdl = cb->smfa_mds_hdl;
	svc_info.i_svc_id = NCSMDS_SVC_ID_SMFA;
	svc_info.i_op = MDS_SUBSCRIBE;

	svc_info.info.svc_subscribe.i_num_svcs = 1;
	svc_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_INTRANODE;
	svc_info.info.svc_subscribe.i_svc_ids = svc_id;
	if (NCSCC_RC_SUCCESS != ncsmds_api(&svc_info)){
		LOG_ER("SMFA: MDS Subscription FAILED.");
		smfa_mds_unregister();
		return NCSCC_RC_FAILURE;
	}
	
	return NCSCC_RC_SUCCESS;	 
}
コード例 #23
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;
}
コード例 #24
0
ファイル: avnd.c プロジェクト: kenzaburo/OpenSaf-FrameWork
/****************************************************************************
  Name          : avnd_ext_intf_destroy
 
  Description   : This routine destroys external interfaces (logging service
                  being the exception).
 
  Arguments     : cb - ptr to AvND control block
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
uns32 avnd_ext_intf_destroy(AVND_CB *cb)
{
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();

	/* MDS unregistration */
	rc = avnd_mds_unreg(cb);
	if (NCSCC_RC_SUCCESS != rc)
		goto done;

	/* EDU cleanup */
	m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl);

	m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl_avnd);

	m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl_ava);

	/* NTFA Finalize */
	rc = saNtfFinalize(cb->ntfHandle);
	if (rc != SA_AIS_OK) {
		LOG_ER("saNtfFinalize Failed (%u)", rc);
	}
 done:
	TRACE_LEAVE();
	return rc;
}
コード例 #25
0
ファイル: plma_mds.c プロジェクト: helioloureiro/opensaf-fork
/***********************************************************************//**
* @brief	This function un-registers the PLMA Service with MDS.
*
* @return	NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
***************************************************************************/
void plma_mds_unregister()
{
	NCSMDS_INFO arg;
	uint32_t rc;
	PLMA_CB *plma_cb = plma_ctrlblk;

	TRACE_ENTER();

	/** 
	 * Un-install your service into MDS.
	 * No need to cancel the services that are subscribed 
	 */
	memset(&arg, 0, sizeof(NCSMDS_INFO));

	arg.i_mds_hdl = plma_cb->mds_hdl;
	arg.i_svc_id = NCSMDS_SVC_ID_PLMA;
	arg.i_op = MDS_UNINSTALL;

	if ((rc = ncsmds_api(&arg)) != NCSCC_RC_SUCCESS) {
		LOG_ER("PLMA - MDS Unregister Failed rc:%u", rc);
		goto done;
       }
done:
	TRACE_LEAVE();
	return;
}
コード例 #26
0
/***********************************************************************//**
* @brief	This routine is used to destroy the group info tree.
*
* @return	NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
***************************************************************************/
uns32 plma_group_tree_destroy()
{
	/* cleanup the client tree */
	PLMA_CB *cb = plma_ctrlblk;
	PLMA_ENTITY_GROUP_INFO *grp_info_node;
	SaPlmEntityGroupHandleT *temp_ptr = 0;
	SaPlmEntityGroupHandleT temp_hdl = 0;
	uns32    rc = NCSCC_RC_SUCCESS;

	TRACE_ENTER();	
	/* scan the entire handle db & delete each record */
	while ((grp_info_node = (PLMA_ENTITY_GROUP_INFO *)
		ncs_patricia_tree_getnext(&cb->entity_group_info, (uns8 *)temp_ptr)))
	{		
		/* delete the client info */
		temp_hdl = grp_info_node->entity_group_handle;
		temp_ptr = &temp_hdl;

		 if (grp_info_node != NULL){
			/* Remove the Node from the client tree */
			if (ncs_patricia_tree_del(&cb->entity_group_info, &grp_info_node->pat_node) != NCSCC_RC_SUCCESS){
				LOG_ER("PLMA: GROUP_INFO NODE DELETE FAILED");
		                rc = NCSCC_RC_FAILURE;
	        	}
			clean_group_info_node(grp_info_node);
			free(grp_info_node);
		 }
							
			
	}
	TRACE_LEAVE();
	return rc;
}
コード例 #27
0
/****************************************************************************\
 * Function: avnd_mbcsv_process_err_ind
 *
 * Purpose:  AVND MBCSV process error indication.
 *
 * Input: arg - MBCSV callback argument pointer.
 *
 * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
 *
 * NOTES:
 *
 * 
\**************************************************************************/
static uns32 avnd_mbcsv_process_err_ind(AVND_CB *cb, NCS_MBCSV_CB_ARG *arg)
{

	TRACE_ENTER2("error code is %u",arg->info.error.i_code);

	switch (arg->info.error.i_code) {
	case NCS_MBCSV_COLD_SYNC_TMR_EXP:
		break;

	case NCS_MBCSV_WARM_SYNC_TMR_EXP:
		break;

	case NCS_MBCSV_DATA_RSP_CMPLT_TMR_EXP:
		break;

	case NCS_MBCSV_COLD_SYNC_CMPL_TMR_EXP:
		break;

	case NCS_MBCSV_WARM_SYNC_CMPL_TMR_EXP:
		break;

	case NCS_MBCSV_DATA_RESP_TERMINATED:
		break;

	default:
		LOG_ER("Invalid mbcsv error indication");
		break;
	}

	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
コード例 #28
0
ファイル: ntfs_amf.c プロジェクト: helioloureiro/opensaf-fork
/*****************************************************************************\
 *  Name:          ntfs_healthcheck_start                           * 
 *                                                                            *
 *  Description:   To start the health check                                  *
 *                                                                            *
 *  Arguments:     NCSSA_CB* - Control Block                                  * 
 *                                                                            * 
 *  Returns:       SA_AIS_OK    - everything is OK                            *
 *                 SA_AIS_ERR_* -  failure                                    *
 *  NOTE:                                                                     * 
\******************************************************************************/
SaAisErrorT ntfs_amf_healthcheck_start()
{
	SaAisErrorT error;
	SaAmfHealthcheckKeyT healthy;
	char *health_key;

	TRACE_ENTER();

    /** start the AMF health check **/
	memset(&healthy, 0, sizeof(healthy));
	health_key = (char *)getenv("NTFSV_ENV_HEALTHCHECK_KEY");

	if (health_key == NULL) {
		strncpy((char *)healthy.key, "F1B2", SA_AMF_HEALTHCHECK_KEY_MAX);
		healthy.keyLen = strlen((const char *)healthy.key);
	} else {
		healthy.keyLen = strlen(health_key);
		if (healthy.keyLen > sizeof(healthy.key))
			healthy.keyLen = sizeof(healthy.key);
		strncpy((char *)healthy.key, health_key, healthy.keyLen);
	}

	error = saAmfHealthcheckStart(ntfs_cb->amf_hdl, &ntfs_cb->comp_name, &healthy,
				      SA_AMF_HEALTHCHECK_AMF_INVOKED, SA_AMF_COMPONENT_FAILOVER);

	if (error != SA_AIS_OK)
		LOG_ER("saAmfHealthcheckStart FAILED: %u", error);

	TRACE_LEAVE();
	return error;
}
コード例 #29
0
void parseArgs(QStringList args)
{
  QSettings settings;

  QString sDefaultHostName = QHostInfo::localHostName();
  QString sHostName = settings.value("hostname", QVariant(sDefaultHostName)).toString();
  settings.setValue("hostname", QVariant(sHostName));
  LOG_IN(QString("SETTINGS host name: %1").arg(sHostName));

  QString sDefaultPort = "54340";
  QString sPort = settings.value("port", QVariant(sDefaultPort)).toString();
  settings.setValue("port", QVariant(sPort));
  LOG_IN(QString("SETTINGS host port: %1").arg(sPort));

  QString sDefaultRootPath = QString("%1/.Hobbyist_Software/VLC_Streamer/Root").arg(QDir::homePath());
  QString sRootPath = settings.value("root", QVariant(sDefaultRootPath)).toString();
  settings.setValue("root", QVariant(sRootPath));
  LOG_IN(QString("SETTINGS root: %1").arg(sRootPath));

  LOG_IN(QString("SETTINGS settings file %1").arg(settings.fileName()));

  if (!settings.isWritable())
  {
    LOG_ER(QString("SETTINGS could not write file"));
  }

  settings.sync();
}
コード例 #30
0
ファイル: eds_evt.c プロジェクト: helioloureiro/opensaf-fork
/****************************************************************************
 * Name          : eds_proc_chan_unlink_msg
 *
 * Description   : This is the function which is called when eds receives a
 *                 EDSV_EDA_CHAN_UNLINK message.
 *
 * Arguments     : msg  - Message that was posted to the EDS Mail box.
 *
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t eds_proc_chan_unlink_msg(EDS_CB *cb, EDSV_EDS_EVT *evt)
{
	uint32_t rc = NCSCC_RC_SUCCESS, rs = NCSCC_RC_SUCCESS, async_rc = NCSCC_RC_SUCCESS;
	EDSV_EDA_CHAN_UNLINK_PARAM *unlink_param;
	EDSV_MSG msg;
	EDS_CKPT_DATA ckpt;
	TRACE_ENTER2("agent dest: %" PRIx64, evt->fr_dest);

	unlink_param = &(evt->info.msg.info.api_info.param.chan_unlink);
	rs = eds_channel_unlink(cb, unlink_param->chan_name.length, unlink_param->chan_name.value);
	if (rs != SA_AIS_OK)
		TRACE("Channel unlink failed for :%" PRIx64, evt->fr_dest);

	/* Send response back */
	m_EDS_EDSV_CHAN_UNLINK_SYNC_MSG_FILL(msg, rs, unlink_param->chan_name)
	    rc = eds_mds_msg_send(cb, &msg, &evt->fr_dest, &evt->mds_ctxt, MDS_SEND_PRIORITY_HIGH);
	if (rc != NCSCC_RC_SUCCESS)
		LOG_ER("MDS send to %" PRIx64 " failed for saEvtChannelUnlink()", evt->fr_dest);

	if (rs == SA_AIS_OK) {	/* Send an Async update to STANDBY EDS peer */
		if (cb->ha_state == SA_AMF_HA_ACTIVE) {
			memset(&ckpt, 0, sizeof(ckpt));
			m_EDSV_FILL_ASYNC_UPDATE_CUNLINK(ckpt, unlink_param->chan_name.value,
							 unlink_param->chan_name.length)
			async_rc = send_async_update(cb, &ckpt, NCS_MBCSV_ACT_ADD);
			if (async_rc != NCSCC_RC_SUCCESS)
				TRACE("Async update send failed for unlink msg");
		}
	}
	TRACE_LEAVE();
	return rc;
}