コード例 #1
0
/****************************************************************************
  Name          : immnd_mds_enc_flat
 
  Description   : This function encodes an events sent from IMMA/IMMD.
 
  Arguments     : cb    : IMMND control Block.
                  enc_info  : Info for encoding
  
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
static uint32_t immnd_mds_enc_flat(IMMND_CB *cb, MDS_CALLBACK_ENC_FLAT_INFO *info)
{
	IMMSV_EVT *evt;
	uint32_t rc = NCSCC_RC_SUCCESS;
	NCS_UBAID *uba = info->io_uba;

	/* as all the event structures are flat */
	/* Get the Msg Format version from the SERVICE_ID & 
	   RMT_SVC_PVT_SUBPART_VERSION */
	if (info->i_to_svc_id == NCSMDS_SVC_ID_IMMA_OM) {
		/*
		   info->o_msg_fmt_ver = 
		   m_NCS_ENC_MSG_FMT_GET(info->i_rem_svc_pvt_ver,
		   IMMND_WRT_IMMA_OM_SUBPART_VER_MIN,
		   IMMND_WRT_IMMA_OM_SUBPART_VER_MAX,
		   immnd_imma_msg_fmt_table);
		 */
	} else if (info->i_to_svc_id == NCSMDS_SVC_ID_IMMA_OI) {
		/*
		   info->o_msg_fmt_ver = 
		   m_NCS_ENC_MSG_FMT_GET(info->i_rem_svc_pvt_ver,
		   IMMND_WRT_IMMA_OI_SUBPART_VER_MIN,
		   IMMND_WRT_IMMA_OI_SUBPART_VER_MAX,
		   immnd_imma_msg_fmt_table);
		 */
	} else if (info->i_to_svc_id == NCSMDS_SVC_ID_IMMND) {
		/*
		   info->o_msg_fmt_ver = 
		   m_NCS_ENC_MSG_FMT_GET(info->i_rem_svc_pvt_ver,
		   IMMND_WRT_IMMND_SUBPART_VER_MIN,
		   IMMND_WRT_IMMND_SUBPART_VER_MAX,
		   immnd_immnd_msg_fmt_table);
		 */
	} else if (info->i_to_svc_id == NCSMDS_SVC_ID_IMMD) {
		info->o_msg_fmt_ver =
		    m_NCS_ENC_MSG_FMT_GET(info->i_rem_svc_pvt_ver,
					  IMMND_WRT_IMMD_SUBPART_VER_MIN,
					  IMMND_WRT_IMMD_SUBPART_VER_MAX, immnd_immd_msg_fmt_table);
	}

	if (1 /*info->o_msg_fmt_ver */ ) {	/* TODO: ABT Does not work */
		evt = (IMMSV_EVT *)info->i_msg;
		rc = immsv_evt_enc_flat( /*&cb->immnd_edu_hdl, */ evt, uba);
		if (rc != NCSCC_RC_SUCCESS) {
			LOG_WA("MDS Encode Flat Failed");
		}
		return rc;
	}
	/* Drop The Message  Incompatible Message Format Version */
	LOG_WA("INVALID MSG FORMAT IN ENCODE FLAT");
	return NCSCC_RC_FAILURE;
}
コード例 #2
0
SaAisErrorT immnd_mds_client_not_busy(IMMSV_SEND_INFO *s_info) 
{
	if(!(s_info->to_svc)) {
		/* No current syncronous reply pending. */
		osafassert(!(s_info->mSynReqCount));
		return SA_AIS_OK;
	}

	/* Client is currently blocked waiting on reply. 
	   This can happen if client has timed out in library
	   on previous syncronous call. The call is here still
	   being processed in the server. The server can then
	   only reply immediately to this client, on *this* call.

	   It could also happen if one handle is used concurrently
	   by several client threads, making concurrent synchronous calls.
	   This is not allowed though, see osaf/services/saf/immsv/README.
	*/

	if(s_info->mSynReqCount < 255) {
		s_info->mSynReqCount++;
		TRACE_2("ERR_TRY_AGAIN: Handle is busy with other syncronous call");
		return SA_AIS_ERR_TRY_AGAIN;
	}

	LOG_WA("ERR_BAD_HANDLE: Handle use is blocked by pending reply on syncronous call");
	return SA_AIS_ERR_BAD_HANDLE;
}
コード例 #3
0
ファイル: eds_tmr.c プロジェクト: helioloureiro/opensaf-fork
/*****************************************************************************
  PROCEDURE NAME : eds_start_tmr

  DESCRIPTION    : Starts the EDS timer. If the timer is already active, it 
                   is restarted (ie. stopped & started without reallocating the 
                   tmr block).

  ARGUMENTS      : cb     - ptr to the EDS control block
                   tmr    - ptr to the EDS timer block
                   type   - timer type
                   period - timer period
                   uarg   - opaque handle that is returned on timer expiry

  RETURNS        : NCSCC_RC_SUCCESS - Success
                   NCSCC_RC_FAILURE  - Failure

  NOTES         : None
*****************************************************************************/
uint32_t eds_start_tmr(EDS_CB *cb, EDS_TMR *tmr, EDS_TMR_TYPE type, SaTimeT period, uint32_t uarg)
{
	uint32_t tmr_period = (uint32_t)(period / EDSV_NANOSEC_TO_LEAPTM);

	if (EDS_TMR_MAX <= tmr->type) {
		LOG_WA("Unsupported timer type");
		TRACE_LEAVE();
		return NCSCC_RC_FAILURE;
	}

	if (tmr->tmr_id == TMR_T_NULL) {
		tmr->type = type;
		m_NCS_TMR_CREATE(tmr->tmr_id, (uint32_t)tmr_period, eds_tmr_exp, (void *)tmr);
	}

	if (tmr->is_active == true) {
		m_NCS_TMR_STOP(tmr->tmr_id);
		tmr->is_active = false;
	}

	tmr->opq_hdl = uarg;
	tmr->cb_hdl = cb->my_hdl;
	m_NCS_TMR_START(tmr->tmr_id, (uint32_t)tmr_period, eds_tmr_exp, (void *)tmr);

	tmr->is_active = true;

	if (TMR_T_NULL == tmr->tmr_id) {
		LOG_NO("Timer start failed: type: %u, Id: %p, period: %u", type, tmr->tmr_id, tmr_period);
		TRACE_LEAVE();
		return NCSCC_RC_FAILURE;
	}

	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
コード例 #4
0
static uint32_t immnd_mds_rcv(IMMND_CB *cb, MDS_CALLBACK_RECEIVE_INFO *rcv_info)
{
	uint32_t rc = NCSCC_RC_SUCCESS;
	IMMSV_EVT *pEvt = (IMMSV_EVT *)rcv_info->i_msg;
	/*IMMND_SYNC_SEND_NODE *node = NULL; */

	pEvt->sinfo.ctxt = rcv_info->i_msg_ctxt;
	pEvt->sinfo.dest = rcv_info->i_fr_dest;
	pEvt->sinfo.to_svc = rcv_info->i_fr_svc_id;
	if (rcv_info->i_rsp_reqd) {
		pEvt->sinfo.stype = MDS_SENDTYPE_SNDRSP;
	}

	/* Put it in IMMND's Event Queue */
	if (pEvt->info.immnd.type == IMMND_EVT_A2ND_IMM_INIT)
		rc = m_NCS_IPC_SEND(&cb->immnd_mbx, (NCSCONTEXT)pEvt, NCS_IPC_PRIORITY_HIGH);
	else
		rc = m_NCS_IPC_SEND(&cb->immnd_mbx, (NCSCONTEXT)pEvt, NCS_IPC_PRIORITY_NORMAL);

	if (NCSCC_RC_SUCCESS != rc) {
		LOG_WA("NCS IPC Send Failed");
	}

	return rc;
}
コード例 #5
0
/****************************************************************************
  Name          : immnd_mds_dec_flat
 
  Description   : This function decodes an events sent to IMMND.
 
  Arguments     : cb    : IMMND control Block.
                  dec_info  : Info for decoding
  
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
static uint32_t immnd_mds_dec_flat(IMMND_CB *cb, MDS_CALLBACK_DEC_FLAT_INFO *info)
{
	IMMSV_EVT *evt;
	NCS_UBAID *uba = info->io_uba;
	uint32_t rc = NCSCC_RC_SUCCESS;

	evt = calloc(1, sizeof(IMMSV_EVT));
	if (evt == NULL) {
		LOG_WA("calloc failed");
		return NCSCC_RC_FAILURE;
	}
	info->o_msg = evt;
	rc = immsv_evt_dec_flat(uba, evt);
	if (rc != NCSCC_RC_SUCCESS) {
		free(evt);
		info->o_msg = NULL;
		LOG_WA("MDS Decode Flat Failed");
	}
	return rc;
}
コード例 #6
0
/****************************************************************************
 * Name          : immnd_mds_send_rsp
 *
 * Description   : Send the Response to Sync Requests
 *
 * Arguments     : 
 *
 * Return Values : 
 *
 * Notes         :
 *****************************************************************************/
uint32_t immnd_mds_send_rsp(IMMND_CB *cb, IMMSV_SEND_INFO *s_info, IMMSV_EVT *evt)
{
	NCSMDS_INFO mds_info;
	uint32_t rc;

	if(!(s_info->to_svc)) {
		LOG_WA(">>s_info->to_svc == 0<< reply context destroyed before "
			"this reply could be made");
		return NCSCC_RC_FAILURE;
	}

	osafassert(s_info->stype == MDS_SENDTYPE_SNDRSP);

	memset(&mds_info, 0, sizeof(NCSMDS_INFO));
	mds_info.i_mds_hdl = cb->immnd_mds_hdl;
	mds_info.i_svc_id = NCSMDS_SVC_ID_IMMND;
	mds_info.i_op = MDS_SEND;

	/* fill the send structure */
	mds_info.info.svc_send.i_msg = (NCSCONTEXT)evt;
	mds_info.info.svc_send.i_priority = MDS_SEND_PRIORITY_MEDIUM;

	mds_info.info.svc_send.i_to_svc = s_info->to_svc;
	mds_info.info.svc_send.i_sendtype = MDS_SENDTYPE_RSP;
	mds_info.info.svc_send.info.rsp.i_msg_ctxt = s_info->ctxt;
	mds_info.info.svc_send.info.rsp.i_sender_dest = s_info->dest;

	immsv_msg_trace_send(s_info->dest, evt);

	/* send the message */
	rc = ncsmds_api(&mds_info);

	/* Destroy reply context after reply has been sent
	   Will also zero mSyncReqCount */
	memset(s_info, 0, sizeof(IMMSV_SEND_INFO));

	if (rc != NCSCC_RC_SUCCESS)
		LOG_WA("MDS Send Failed");

	return rc;
}
コード例 #7
0
ファイル: lgs_amf.c プロジェクト: helioloureiro/opensaf-fork
static void close_all_files(void)
{
	log_stream_t *stream;

	stream = log_stream_getnext_by_name(NULL);
	while (stream != NULL) {
		if (log_stream_file_close(stream) != 0)
			LOG_WA("Could not close file for stream %s", stream->name);

		stream = log_stream_getnext_by_name(stream->name);
	}
}
コード例 #8
0
static uint32_t immnd_mds_dec(IMMND_CB *cb, MDS_CALLBACK_DEC_INFO *dec_info)
{

	IMMSV_EVT *evt;
	uint32_t rc = NCSCC_RC_SUCCESS;

	evt = calloc(1, sizeof(IMMSV_EVT));
	if (!evt) {
		LOG_WA("calloc failed");
		return NCSCC_RC_FAILURE;
	}

	dec_info->o_msg = (NCSCONTEXT)evt;

	rc = immsv_evt_dec( /*&cb->immnd_edu_hdl, */ dec_info->io_uba, evt);
	if (rc != NCSCC_RC_SUCCESS) {
		LOG_WA("MDS Decode Failed");
		free(dec_info->o_msg);
		dec_info->o_msg = NULL;
	}
	return rc;
}
コード例 #9
0
/****************************************************************************
 * Name          : immnd_mds_get_handle
 *
 * Description   : This function Gets the Handles of local MDS destination
 *
 * Arguments     : cb   : IMMND control Block pointer.
 *
 * Return Values : NCSCC_RC_SUCCESS/Error Code.
 *
 * Notes         : None.
 *****************************************************************************/
uint32_t immnd_mds_get_handle(IMMND_CB *cb)
{
	NCSADA_INFO arg;
	uint32_t rc;

	memset(&arg, 0, sizeof(NCSADA_INFO));
	arg.req = NCSADA_GET_HDLS;
	rc = ncsada_api(&arg);

	if (rc != NCSCC_RC_SUCCESS) {
		LOG_WA("MDS Handle Get Failed");
		return rc;
	}
	cb->immnd_mds_hdl = arg.info.adest_get_hdls.o_mds_pwe1_hdl;
	return rc;
}
コード例 #10
0
/****************************************************************************
  Name          : immnd_mds_enc
 
  Description   : This function encodes an events sent from IMMND.
 
  Arguments     : cb    : IMMND control Block.
                  info  : Info for encoding
  
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
static uint32_t immnd_mds_enc(IMMND_CB *cb, MDS_CALLBACK_ENC_INFO *enc_info)
{
	IMMSV_EVT *evt;

	/* Get the Msg Format version from the SERVICE_ID & 
	   RMT_SVC_PVT_SUBPART_VERSION */
	if (enc_info->i_to_svc_id == NCSMDS_SVC_ID_IMMA_OM) {
		/*
		   enc_info->o_msg_fmt_ver = 
		   m_NCS_ENC_MSG_FMT_GET(enc_info->i_rem_svc_pvt_ver,
		   IMMND_WRT_IMMA_OM_SUBPART_VER_MIN,
		   IMMND_WRT_IMMA_OM_SUBPART_VER_MAX,
		   immnd_imma_msg_fmt_table);
		 */
	} else if (enc_info->i_to_svc_id == NCSMDS_SVC_ID_IMMA_OI) {
		/*
		   enc_info->o_msg_fmt_ver = 
		   m_NCS_ENC_MSG_FMT_GET(enc_info->i_rem_svc_pvt_ver,
		   IMMND_WRT_IMMA_OI_SUBPART_VER_MIN,
		   IMMND_WRT_IMMA_OI_SUBPART_VER_MAX,
		   immnd_imma_msg_fmt_table);
		 */
	} else if (enc_info->i_to_svc_id == NCSMDS_SVC_ID_IMMND) {
		/*
		   enc_info->o_msg_fmt_ver = 
		   m_NCS_ENC_MSG_FMT_GET(enc_info->i_rem_svc_pvt_ver,
		   IMMND_WRT_IMMND_SUBPART_VER_MIN,
		   IMND_WRT_IMMND_SUBPART_VER_MAX,
		   immnd_immnd_msg_fmt_table);
		 */
	} else if (enc_info->i_to_svc_id == NCSMDS_SVC_ID_IMMD) {
		enc_info->o_msg_fmt_ver =
		    m_NCS_ENC_MSG_FMT_GET(enc_info->i_rem_svc_pvt_ver,
					  IMMND_WRT_IMMD_SUBPART_VER_MIN,
					  IMMND_WRT_IMMD_SUBPART_VER_MAX, immnd_immd_msg_fmt_table);
	}

	if (1 /*enc_info->o_msg_fmt_ver */ ) {	/*TODO: ABT Does not work */
		evt = (IMMSV_EVT *)enc_info->i_msg;

		return immsv_evt_enc( /*&cb->immnd_edu_hdl, */ evt, enc_info->io_uba);
	}

	/* Drop The Message - Incompatible Message Format Version */
	LOG_WA("INVALID MSG FORMAT IN ENCODE FULL");
	return NCSCC_RC_FAILURE;
}
コード例 #11
0
ファイル: immd_db.c プロジェクト: kenzaburo/OpenSaf-FrameWork
/****************************************************************************
  Name          : immd_immnd_info_node_delete
  Description   : This routine deletes the immnd_info node from tree
  Arguments     : IMMD_CB *cb - IMMD Control Block.
                : IMMD_IMMND_INFO_NODE *immnd_info - IMMND Info Node.
  Return Values : None
*****************************************************************************/
uns32 immd_immnd_info_node_delete(IMMD_CB *cb, IMMD_IMMND_INFO_NODE *immnd_info_node)
{
	uns32 rc = NCSCC_RC_SUCCESS;

	/* Remove the Node from the client tree */
	if (ncs_patricia_tree_del(&cb->immnd_tree, &immnd_info_node->patnode) != NCSCC_RC_SUCCESS) {
		LOG_WA("IMMD - IMMND INFO NODE DELETE FROM PAT TREE FAILED");
		rc = NCSCC_RC_FAILURE;
	}

	/* Free the Client Node */
	if (immnd_info_node) {
		free(immnd_info_node);
	}

	return rc;
}
コード例 #12
0
/****************************************************************************
  Name          : immnd_mds_msg_send
 
  Description   : This routine sends the Events from IMMND
 
  Arguments     : cb  - ptr to the IMMND CB
                  i_evt - ptr to the IMMSV message
                  o_evt - ptr to the IMMSV message returned
                  timeout - timeout value in 10 ms 
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uint32_t immnd_mds_msg_send(IMMND_CB *cb, uint32_t to_svc, MDS_DEST to_dest, IMMSV_EVT *evt)
{
	NCSMDS_INFO mds_info;
	uint32_t rc;

	if (!evt)
		return NCSCC_RC_FAILURE;

	m_NCS_LOCK(&cb->immnd_immd_up_lock, NCS_LOCK_WRITE);

	if ((to_svc == NCSMDS_SVC_ID_IMMD) && (cb->is_immd_up == false)) {
		/* IMMD is not UP */
		TRACE_2("Director Service Is Down");
		m_NCS_UNLOCK(&cb->immnd_immd_up_lock, NCS_LOCK_WRITE);
		return NCSCC_RC_FAILURE;
	}

	m_NCS_UNLOCK(&cb->immnd_immd_up_lock, NCS_LOCK_WRITE);

	memset(&mds_info, 0, sizeof(NCSMDS_INFO));
	mds_info.i_mds_hdl = cb->immnd_mds_hdl;
	mds_info.i_svc_id = NCSMDS_SVC_ID_IMMND;
	mds_info.i_op = MDS_SEND;

	/* fill the send structure */
	mds_info.info.svc_send.i_msg = (NCSCONTEXT)evt;
	mds_info.info.svc_send.i_priority = MDS_SEND_PRIORITY_MEDIUM;
	mds_info.info.svc_send.i_to_svc = to_svc;
	mds_info.info.svc_send.i_sendtype = MDS_SENDTYPE_SND;
	mds_info.info.svc_send.info.snd.i_to_dest = to_dest;

	immsv_msg_trace_send(to_dest, evt);

	/* send the message */
	rc = ncsmds_api(&mds_info);

	if (rc != NCSCC_RC_SUCCESS) {
		LOG_WA("MDS Send Failed to service:%s rc:%u",
		       (to_svc == NCSMDS_SVC_ID_IMMD) ? "IMMD" :
		       (to_svc == NCSMDS_SVC_ID_IMMA_OM) ? "IMMA OM" :
		       (to_svc == NCSMDS_SVC_ID_IMMA_OI) ? "IMMA OI" :
		       (to_svc == NCSMDS_SVC_ID_IMMND) ? "IMMND" : "NO SERVICE!", rc);
	}

	return rc;
}
コード例 #13
0
ファイル: smfd_evt.c プロジェクト: indonexia2004/opensaf-indo
/****************************************************************************
 * Name          : proc_mds_info
 *
 * Description   : Handle a mds info event 
 *
 * Arguments     : cb  - SMFND control block  
 *                 evt - The MDS_INFO event
 *
 * Return Values : None.
 *
 * Notes         : None.
 *****************************************************************************/
static void proc_mds_info(smfd_cb_t * cb, SMFSV_EVT * evt)
{
	smfsv_mds_info *mds_info = &evt->info.smfd.event.mds_info;

	switch (mds_info->change) {

	case NCSMDS_RED_UP:
		/* get the peer mds_red_up */

		break;

	case NCSMDS_UP:

		if (mds_info->svc_id == NCSMDS_SVC_ID_SMFD) {
			return;
		}

		if (mds_info->svc_id == NCSMDS_SVC_ID_SMFND) {
			if(smfnd_up(mds_info->node_id, mds_info->dest, mds_info->rem_svc_pvt_ver) == SA_AIS_OK)
				cb->no_of_smfnd++;
			else
				LOG_WA("SMFND UP failed");
		}
		break;

	case NCSMDS_DOWN:

		if (mds_info->svc_id == NCSMDS_SVC_ID_SMFD) {
			return;
		}

		if (mds_info->svc_id == NCSMDS_SVC_ID_SMFND) {
			smfnd_down(mds_info->node_id);
			cb->no_of_smfnd--;
		}
		break;

	default:

		break;
	}

	return;
}
コード例 #14
0
/****************************************************************************
 * Name          : immnd_mds_unregister
 *
 * Description   : This function un-registers the IMMND Service with MDS.
 *
 * Arguments     : cb   : IMMND control Block pointer.
 *
 * Return Values : None
 *
 * Notes         : None.
 *****************************************************************************/
void immnd_mds_unregister(IMMND_CB *cb)
{
	NCSMDS_INFO arg;
	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 = cb->immnd_mds_hdl;
	arg.i_svc_id = NCSMDS_SVC_ID_IMMND;
	arg.i_op = MDS_UNINSTALL;

	if (ncsmds_api(&arg) != NCSCC_RC_SUCCESS) {
		LOG_WA("MDS Unregister Failed");
	}
	TRACE_LEAVE();
	return;
}
コード例 #15
0
/****************************************************************************\
 * Function: avsv_mbcsv_process_err_ind
 *
 * Purpose:  AVSV MBCSV process error indication.
 *
 * Input: arg - MBCSV callback argument pointer.
 *
 * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
 *
 * NOTES:
 *
 * 
\**************************************************************************/
static uns32 avsv_mbcsv_process_err_ind(AVD_CL_CB *cb, NCS_MBCSV_CB_ARG *arg)
{
	switch (arg->info.error.i_code) {
	case NCS_MBCSV_COLD_SYNC_TMR_EXP:
		/* The first cold sync request seems to be ignored so don't log */
		TRACE("mbcsv cold sync tmr exp");
		break;

	case NCS_MBCSV_WARM_SYNC_TMR_EXP:
		LOG_WA("mbcsv warm sync tmr exp");
		break;

	case NCS_MBCSV_DATA_RSP_CMPLT_TMR_EXP:
		LOG_WA("mbcsv data rsp cmplt tmr exp");
		break;

	case NCS_MBCSV_COLD_SYNC_CMPL_TMR_EXP:
		LOG_WA("mbcsv cold sync cmpl tmr exp");
		break;

	case NCS_MBCSV_WARM_SYNC_CMPL_TMR_EXP:
		LOG_WA("mbcsv warm sync cmpl tmr exp");
		break;

	case NCS_MBCSV_DATA_RESP_TERMINATED:
		LOG_WA("mbcsv data rsp term");
		break;

	case NCS_MBCSV_COLD_SYNC_RESP_TERMINATED:
		LOG_WA("mbcsv cold sync rsp term");
		break;

	case NCS_MBCSV_WARM_SYNC_RESP_TERMINATED:
		LOG_WA("mbcsv warm sync rsp term");
		break;

	default:
		LOG_IN("mbcsv unknown ecode %u", arg->info.error.i_code);
		break;
	}

	return NCSCC_RC_SUCCESS;
}
コード例 #16
0
ファイル: smfd_mds.c プロジェクト: helioloureiro/opensaf-fork
static uint32_t mds_dec(struct ncsmds_callback_info *info)
{
	SMFSV_EVT *evt;
	NCS_UBAID *uba = info->info.dec.io_uba;

    /** allocate an SMFSV_EVENT now **/
	if (NULL == (evt = calloc(1, sizeof(SMFSV_EVT)))) {
		LOG_WA("calloc FAILED");
		goto err;
	}

	/* Assign the allocated event */
	info->info.dec.o_msg = (uint8_t *) evt;

	if (smfsv_evt_dec(uba, evt) != NCSCC_RC_SUCCESS) {
		TRACE("decoding event %d failed", evt->type);
		goto err;
	}

	return NCSCC_RC_SUCCESS;

 err:
	return NCSCC_RC_FAILURE;
}
コード例 #17
0
ファイル: lgs_amf.c プロジェクト: helioloureiro/opensaf-fork
/****************************************************************************
 * Name          : amf_csi_set_callback
 *
 * Description   : AMF callback function called 
 *                 when there is any change in the HA state.
 *
 * 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 state the Availability
 *                                  Management Framework is setting.
 *                 haState        - The new HA state to be assumed by the
 *                                  component service instance identified by
 *                                  csiName.
 *                 csiDescriptor - This will indicate whether or not the
 *                                  component service instance for
 *                                  ativeCompName went through quiescing.
 *
 * Return Values : None.
 *
 * Notes         : None.
 *****************************************************************************/
static void amf_csi_set_callback(SaInvocationT invocation,
		const SaNameT *compName, SaAmfHAStateT new_haState,
		SaAmfCSIDescriptorT csiDescriptor)
{
	SaAisErrorT error = SA_AIS_OK;
	SaAmfHAStateT prev_haState;
	bool role_change = true;
	uint32_t rc = NCSCC_RC_SUCCESS;

	TRACE_ENTER();

	/*
	 *  Handle Active to Active role change.
	 */
	prev_haState = lgs_cb->ha_state;

	/* Invoke the appropriate state handler routine */
	switch (new_haState) {
	case SA_AMF_HA_ACTIVE:
		error = amf_active_state_handler(lgs_cb, invocation);
		break;
	case SA_AMF_HA_STANDBY:
		error = amf_standby_state_handler(lgs_cb, invocation);
		break;
	case SA_AMF_HA_QUIESCED:
		/* switch-over */
		error = amf_quiesced_state_handler(lgs_cb, invocation);
		break;
	case SA_AMF_HA_QUIESCING:
		/* shutdown admin op */
		error = amf_quiescing_state_handler(lgs_cb, invocation);
		break;
	default:
		LOG_WA("invalid state: %d ", new_haState);
		error = SA_AIS_ERR_FAILED_OPERATION;
		break;
	}

	if (error != SA_AIS_OK)
		goto response;

	if (new_haState == SA_AMF_HA_QUIESCED) {
		/* AMF response will be done later when MDS quiesced ack has been received */
		goto done;
	}

	/* Update control block */
	lgs_cb->ha_state = new_haState;

	if (lgs_cb->csi_assigned == false) {
		lgs_cb->csi_assigned = true;
		/* We shall open checkpoint only once in our life time. currently doing at lib init  */
	} else if ((new_haState == SA_AMF_HA_ACTIVE) || (new_haState == SA_AMF_HA_STANDBY)) {	/* It is a switch over */
		lgs_cb->ckpt_state = COLD_SYNC_IDLE;
		/* NOTE: This behaviour has to be checked later, when scxb redundancy is available 
		 * Also, change role of mds, mbcsv during quiesced has to be done after mds
		 * supports the same.  TBD
		 */
	}

	/* Handle active to active role change. */
	if ((prev_haState == SA_AMF_HA_ACTIVE) && (new_haState == SA_AMF_HA_ACTIVE))
		role_change = false;

	/* Handle Stby to Stby role change. */
	if ((prev_haState == SA_AMF_HA_STANDBY) && (new_haState == SA_AMF_HA_STANDBY))
		role_change = false;

	if (role_change == true) {
		if ((rc = lgs_mds_change_role(lgs_cb)) != NCSCC_RC_SUCCESS) {
			LOG_ER("lgs_mds_change_role FAILED");
			error = SA_AIS_ERR_FAILED_OPERATION;
			goto response;
		}

		/* Inform MBCSV of HA state change */
		if (NCSCC_RC_SUCCESS != (error = lgs_mbcsv_change_HA_state(lgs_cb)))
			error = SA_AIS_ERR_FAILED_OPERATION;
	}

 response:
	saAmfResponse(lgs_cb->amf_hdl, invocation, error);
 done:
	TRACE_LEAVE();
}
コード例 #18
0
ファイル: ntfs_amf.c プロジェクト: helioloureiro/opensaf-fork
/****************************************************************************
 * Name          : amf_csi_set_callback
 *
 * Description   : AMF callback function called 
 *                 when there is any change in the HA state.
 *
 * 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.
 *                 haState        - The new HA state to be assumeb by the 
 *                                  component service instance identified by 
 *                                  csiName.
 *                 csiDescriptor - This will indicate whether or not the 
 *                                  component service instance for 
 *                                  ativeCompName went through quiescing.
 *
 * Return Values : None.
 *
 * Notes         : None.
 *****************************************************************************/
static void amf_csi_set_callback(SaInvocationT invocation,
				 const SaNameT *compName, SaAmfHAStateT new_haState, SaAmfCSIDescriptorT csiDescriptor)
{
	SaAisErrorT error = SA_AIS_OK;
	SaAmfHAStateT prev_haState;
	bool role_change = true;
	uint32_t rc = NCSCC_RC_SUCCESS;

	TRACE_ENTER();

	/*
	 *  Handle Active to Active role change.
	 */
	prev_haState = ntfs_cb->ha_state;

	if (prev_haState == SA_AMF_HA_STANDBY &&
	    new_haState == SA_AMF_HA_ACTIVE && ntfs_cb->ckpt_state != COLD_SYNC_COMPLETE) {
		/* We are not synched and cannot take over */
		LOG_ER("NTFS cannot take over not cold synched");
		error = SA_AIS_ERR_FAILED_OPERATION;
		goto response;
	}

	/* Invoke the appropriate state handler routine */
	switch (new_haState) {
	case SA_AMF_HA_ACTIVE:
		error = amf_active_state_handler(invocation);
		break;
	case SA_AMF_HA_STANDBY:
		error = amf_standby_state_handler(invocation);
		break;
	case SA_AMF_HA_QUIESCED:
		error = amf_quiesced_state_handler(invocation);
		break;
	case SA_AMF_HA_QUIESCING:
		error = amf_quiescing_state_handler(invocation);
		break;
	default:
		LOG_WA("invalid state: %d ", new_haState);
		error = SA_AIS_ERR_BAD_OPERATION;
		break;
	}

	if (error != SA_AIS_OK)
		goto response;

	if (new_haState == SA_AMF_HA_QUIESCED)
		goto done;

	/* Update control block */
	ntfs_cb->ha_state = new_haState;
	
	if (ntfs_cb->csi_assigned == false) {
		ntfs_cb->csi_assigned = true;
		/* We shall open checkpoint only once in our life time. currently doing at lib init  */
	} else if ((new_haState == SA_AMF_HA_ACTIVE) || (new_haState == SA_AMF_HA_STANDBY)) {	/* It is a switch over */
		/* NOTE: This behaviour has to be checked later, when scxb redundancy is available 
		 * Also, change role of mds, mbcsv during quiesced has to be done after mds
		 * supports the same.  TBD
		 */
	}

	/* Handle active to active role change. */
	if ((prev_haState == SA_AMF_HA_ACTIVE) && (new_haState == SA_AMF_HA_ACTIVE))
		role_change = false;

	/* Handle Stby to Stby role change. */
	if ((prev_haState == SA_AMF_HA_STANDBY) && (new_haState == SA_AMF_HA_STANDBY))
		role_change = false;

	if (role_change == true) {
		if ((rc = ntfs_mds_change_role()) != NCSCC_RC_SUCCESS) {
			LOG_ER("ntfs_mds_change_role FAILED");
			error = SA_AIS_ERR_FAILED_OPERATION;
		}

		/* Inform MBCSV of HA state change */
		if (NCSCC_RC_SUCCESS != (error = ntfs_mbcsv_change_HA_state(ntfs_cb)))
			error = SA_AIS_ERR_FAILED_OPERATION;
		
		TRACE("%s NTFS changing HA role from %s to %s",
				__FUNCTION__,
				ha_state_str(prev_haState),
				ha_state_str(new_haState));
	}

 response:
	saAmfResponse(ntfs_cb->amf_hdl, invocation, error);
	if ((new_haState == SA_AMF_HA_ACTIVE) && (role_change == true)) {
		/* check for unsent notifictions and if notifiction is not logged */
		checkNotificationList();
	}
 done:
	/* Kills the osafntfimcnd process if current state is Active or Standby and
	 * the process is not already running in this state.
	 * The process will be restarted by the process surveillance
	 * thread.
	 * This function will not return until the process is terminated.
	 */
	handle_state_ntfimcn(ntfs_cb->ha_state);

	TRACE_LEAVE();
}
コード例 #19
0
void avd_cluster_tmr_init_evh(AVD_CL_CB *cb, AVD_EVT *evt)
{
	SaNameT lsg_name;
	AVD_SG *i_sg;

	TRACE_ENTER();
	saflog(LOG_NOTICE, amfSvcUsrName, "Cluster startup timeout, assigning SIs to SUs");

	assert(evt->info.tmr.type == AVD_TMR_CL_INIT);

	if (avd_cluster->saAmfClusterAdminState != SA_AMF_ADMIN_UNLOCKED) {
		LOG_WA("Admin state of cluster is locked");
		goto done;
	}

	if (cb->init_state != AVD_INIT_DONE) {
		LOG_ER("wrong state %u", cb->init_state);
		goto done;
	}

	/* change state to application state. */
	cb->init_state = AVD_APP_STATE;
	m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(cb, cb, AVSV_CKPT_AVD_CB_CONFIG);

	/* call the realignment routine for each of the SGs in the
	 * system that are not NCS specific.
	 */

	lsg_name.length = 0;
	for (i_sg = avd_sg_getnext(&lsg_name); i_sg != NULL; i_sg = avd_sg_getnext(&lsg_name)) {
		lsg_name = i_sg->name;

		if ((i_sg->list_of_su == NULL) || (i_sg->sg_ncs_spec == SA_TRUE)) {
			continue;
		}

		switch (i_sg->sg_redundancy_model) {
		case SA_AMF_2N_REDUNDANCY_MODEL:
			avd_sg_2n_realign_func(cb, i_sg);
			break;

		case SA_AMF_N_WAY_REDUNDANCY_MODEL:
			avd_sg_nway_realign_func(cb, i_sg);
			break;

		case SA_AMF_N_WAY_ACTIVE_REDUNDANCY_MODEL:
			avd_sg_nacvred_realign_func(cb, i_sg);
			break;

		case SA_AMF_NPM_REDUNDANCY_MODEL:
			avd_sg_npm_realign_func(cb, i_sg);
			break;

		case SA_AMF_NO_REDUNDANCY_MODEL:
		default:
			avd_sg_nored_realign_func(cb, i_sg);
			break;
		}
	}

done:
	TRACE_LEAVE();
}
コード例 #20
0
ファイル: smfd_amf.c プロジェクト: indonexia2004/opensaf-indo
/****************************************************************************
 * Name          : amf_csi_set_callback
 *
 * Description   : AMF callback function called 
 *                 when there is any change in the HA state.
 *
 * 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.
 *                 haState        - The new HA state to be assumeb by the 
 *                                  component service instance identified by 
 *                                  csiName.
 *                 csiDescriptor - This will indicate whether or not the 
 *                                  component service instance for 
 *                                  ativeCompName went through quiescing.
 *
 * Return Values : None.
 *
 * Notes         : None.
 *****************************************************************************/
static void amf_csi_set_callback(SaInvocationT invocation,
				 const SaNameT * compName,
				 SaAmfHAStateT new_haState,
				 SaAmfCSIDescriptorT csiDescriptor)
{
	SaAisErrorT result = SA_AIS_OK;
	SaAmfHAStateT prev_haState;
	bool role_change = true;
	uint32_t rc = NCSCC_RC_SUCCESS;

	TRACE_ENTER();

	/*
	 *  Handle Active to Active role change.
	 */
	prev_haState = smfd_cb->ha_state;

	/* Invoke the appropriate state handler routine */
	switch (new_haState) {
	case SA_AMF_HA_ACTIVE:
		result = amf_active_state_handler(smfd_cb, invocation);
		break;
	case SA_AMF_HA_STANDBY:
		result = amf_standby_state_handler(smfd_cb, invocation);
		break;
	case SA_AMF_HA_QUIESCED:
		result = amf_quiesced_state_handler(smfd_cb, invocation);
		break;
	case SA_AMF_HA_QUIESCING:
		result = amf_quiescing_state_handler(smfd_cb, invocation);
		break;
	default:
		LOG_WA("invalid state: %d ", new_haState);
		result = SA_AIS_ERR_BAD_OPERATION;
		break;
	}

	if (result != SA_AIS_OK)
		goto response;

	if (new_haState == SA_AMF_HA_QUIESCED)
 	        /* AMF response will be done later when MDS quiesced ack has been received */
		goto done;

	/* Update control block */
	smfd_cb->ha_state = new_haState;

        /* Handle active to active role change. */
        if ((prev_haState == SA_AMF_HA_ACTIVE) && (new_haState == SA_AMF_HA_ACTIVE))
                role_change = false;

        /* Handle Stby to Stby role change. */
        if ((prev_haState == SA_AMF_HA_STANDBY) && (new_haState == SA_AMF_HA_STANDBY))
                role_change = false;

	if (role_change == true) {
		if ((rc = smfd_mds_change_role(smfd_cb)) != NCSCC_RC_SUCCESS) {
			TRACE("smfd_mds_change_role FAILED");
			result = SA_AIS_ERR_FAILED_OPERATION;
			goto response;
		}
	}
 response:
	saAmfResponse(smfd_cb->amf_hdl, invocation, result);
 done:
	TRACE_LEAVE();
}
コード例 #21
0
/**
 * Write a log record to file
 * The file must be opened for append
 * 
 * @param indata[in] Type wlrh_t
 * @param outdata[out], int errno, 0 if no error
 * @param max_outsize[in], always sizeof(int)
 * @return (-1) on error or number of written bytes
 */
int write_log_record_hdl(void *indata, void *outdata, size_t max_outsize, bool *timeout_f)
{
	int rc, bytes_written = 0;
	off_t file_length = 0;
	wlrh_t *params_in = (wlrh_t *) indata;
	/* The logrecord is stored in the indata buffer right after the
	 * wlrh_t structure
	 */
	char *logrecord = (char *) (indata + sizeof(wlrh_t));
	int *errno_out_p = (int *) outdata;
	*errno_out_p = 0;

//#define LLD_DELAY_WRTST /* LLDTEST */
#ifdef LLD_DELAY_WRTST /* Make "file system" hang for n sec at first write */
	static bool lld_once_f = true;
	const unsigned int lld_sleep_sec = 10;
#endif
	
	TRACE_ENTER();
	
 retry:
	rc = write(params_in->fd, &logrecord[bytes_written],
		 params_in->record_size - bytes_written);
	if (rc == -1) {
		if (errno == EINTR)
			goto retry;

		LOG_ER("%s - write FAILED: %s",__FUNCTION__, strerror(errno));
		*errno_out_p = errno;
		goto done;
	} else {
		/* Handle partial writes */
		bytes_written += rc;
		if (bytes_written < params_in->record_size)
			goto retry;
	}
#ifdef LLD_DELAY_WRTST /* LLDTEST Wait first time thread is used */
	if (strstr(logrecord, "xxx")) {
		if (lld_once_f == true) {
			lld_once_f = false;
			TRACE("LLDTEST xxx Hang write");
			//TRACE("LLDTEST: logrecord \"%s\"",logrecord);
			sleep(lld_sleep_sec);
			TRACE("LLDTEST End of sleep");
		}
	}
	if (strstr(logrecord, "yyy")) {
		lld_once_f = true;
		TRACE("LLDTEST yyy Rearmed Hang write");
	}
#endif
 
	/* If the thread was hanging and has timed out and the log record was
	 * written it is invalid and shall be removed from file (log service has
	 * returned SA_AIS_TRY_AGAIN). 
	 */
	osaf_mutex_lock_ordie(&lgs_ftcom_mutex); /* LOCK */
	if (*timeout_f == true) {
		TRACE("Timeout, removing last log record");
		file_length = lseek(params_in->fd, -bytes_written, SEEK_END);
		if (file_length != -1) {
			do { 
				rc = ftruncate(params_in->fd, file_length);
			} while ((rc == -1) && (errno == EINTR));
		}

		if (file_length == -1) {
			LOG_WA("%s - lseek error, Could not remove redundant log record, %s",
					__FUNCTION__,strerror(errno));
		} else if (rc == -1) {
			LOG_WA("%s - ftruncate error, Could not remove redundant log record, %s",
					__FUNCTION__,strerror(errno));			
		}
	}
	osaf_mutex_unlock_ordie(&lgs_ftcom_mutex); /* UNLOCK */
 
done:
	TRACE_LEAVE2("rc = %d",rc);
	return rc;
}
コード例 #22
0
static uint32_t immnd_mds_svc_evt(IMMND_CB *cb, MDS_CALLBACK_SVC_EVENT_INFO *svc_evt)
{
	IMMSV_EVT *evt;
	uint32_t rc = NCSCC_RC_SUCCESS, priority = NCS_IPC_PRIORITY_HIGH;
	TRACE_ENTER();

	if (svc_evt->i_svc_id == NCSMDS_SVC_ID_IMMD) {
		m_NCS_LOCK(&cb->immnd_immd_up_lock, NCS_LOCK_WRITE);

		switch (svc_evt->i_change) {
		case NCSMDS_DOWN:
			TRACE("IMMD SERVICE DOWN => CLUSTER GOING DOWN");
			cb->fevs_replies_pending = 0;
			break;

		case NCSMDS_UP:
			TRACE("NCSMDS_UP for IMMD. cb->is_immd_up = true; (v)dest:%llu",
				(long long unsigned int) svc_evt->i_dest);
			cb->is_immd_up = true;
			cb->immd_mdest_id = svc_evt->i_dest;
			break;

		case NCSMDS_NO_ACTIVE:
			/* Do NOT set cb->is_immd_up to false, messages to IMMD vdest buffered */
			if (cb->fevs_replies_pending) {
				LOG_WA("Director Service in NOACTIVE state - "
				       "fevs replies pending:%u fevs highest processed:%llu",
				       cb->fevs_replies_pending, cb->highestProcessed);
				TRACE("Resetting fevs replies pending to zero");
				cb->fevs_replies_pending = 0;
			} else {
				TRACE("Director Service in NOACTIVE state");
			}
			break;

		case NCSMDS_NEW_ACTIVE:
			TRACE("NCSMDS_NEW_ACTIVE IMMD"); 
			cb->immd_mdest_id = svc_evt->i_dest;
			break;

		case NCSMDS_RED_UP:
			LOG_ER("NCSMDS_RED_UP: SHOULD NOT HAPPEN");
			break;

		case NCSMDS_RED_DOWN:
			LOG_ER("NCSMDS_RED_DOWN: SHOULD NOT HAPPEN");
			break;

		case NCSMDS_CHG_ROLE:
			LOG_ER("NCSMDS_CHG_ROLE: SHOULD NOT HAPPEN");
			break;

		default:
			break;
		}

		priority = NCS_IPC_PRIORITY_VERY_HIGH;

		m_NCS_UNLOCK(&cb->immnd_immd_up_lock, NCS_LOCK_WRITE);
	}

	/* IMMA events from other nodes can not happen */
	if ((svc_evt->i_svc_id == NCSMDS_SVC_ID_IMMA_OM) || (svc_evt->i_svc_id == NCSMDS_SVC_ID_IMMA_OI))
		osafassert(m_NCS_NODE_ID_FROM_MDS_DEST(cb->immnd_mdest_id) == m_NCS_NODE_ID_FROM_MDS_DEST(svc_evt->i_dest));

	/* Send the IMMND_EVT_MDS_INFO to IMMND */
	evt = calloc(1, sizeof(IMMSV_EVT));
	if (evt == NULL) {
		LOG_WA("calloc failed");
		return NCSCC_RC_FAILURE;
	}
	evt->type = IMMSV_EVT_TYPE_IMMND;
	evt->info.immnd.type = IMMND_EVT_MDS_INFO;
	evt->info.immnd.info.mds_info.change = svc_evt->i_change;
	evt->info.immnd.info.mds_info.dest = svc_evt->i_dest;
	evt->info.immnd.info.mds_info.svc_id = svc_evt->i_svc_id;
	evt->info.immnd.info.mds_info.role = svc_evt->i_role;

	/* Put it in IMMND's Event Queue */
	rc = m_NCS_IPC_SEND(&cb->immnd_mbx, (NCSCONTEXT)evt, priority);
	if (rc != NCSCC_RC_SUCCESS) {
		LOG_WA("NCS IPC Send Failed");
	}
	TRACE_LEAVE();
	return rc;
}
コード例 #23
0
/**
 * Make directory. Handles creation of directory path.
 * Creates the relative directory in the directory given by the root path.
 * If the root path does not exist/is not available a root path is created
 * based on the default path.
 * 
 * TBD (Separate ticket):
 * Default path taken from the configuration define PKGLOGDIR.
 * Settings: Read, Write, Exec for User, Group, Other
 * 
 * @param indata[in], Type mld_in_t
 * @param outdata[out], char *, new root dir if changed otherwise '\0'
 * @param max_outsize[in]
 * @return (-1) if error
 */
int make_log_dir_hdl(void *indata, void *outdata, size_t max_outsize)
{
	int rc = 0;
	int mldh_rc = 0;
	mld_in_t *params_in = (mld_in_t *) indata;
	char *out_path = (char *) outdata;
	
	char *relpath = params_in->rel_path;
	char *rootpath = params_in->root_dir;
	char dir_to_make[PATH_MAX];
	char mpath[PATH_MAX];
	char *spath_p;
	char *epath_p;
	struct stat statbuf;
	int n;
	
	TRACE_ENTER();
	
	TRACE("rootpath \"%s\"",rootpath);
	TRACE("relpath \"%s\"",relpath);
	
	/* 
	 * Create root directory if it does not exists.
	 * TBD. Handle via separate ticket
	 * (Create the default root path regardless of what is set in the
	 * configuration object.)
	 */
	out_path[0] = '\0';
	if (lstat(rootpath, &statbuf) != 0) {
#if 0
		rootpath = PKGLOGDIR;
#endif
		strncpy(out_path, rootpath, max_outsize);
		n = snprintf(out_path, max_outsize, "%s", rootpath);
		if (n >= max_outsize) {
			LOG_WA("Invalid root path > max_outsize");
			mldh_rc = -1;
			goto done;
		}
		LOG_NO("LOG Root path does not exist. Will be created");
		TRACE("%s - create rootpath \"%s\"",__FUNCTION__,rootpath);
	}
	
	/*
	 * Create root path without preceding '/' and ending '/'
	 * Example: ro1/ro2/ro3
	 * Check that not > PATH_MAX
	 */
	n = snprintf(mpath, PATH_MAX, "%s", rootpath);
	if (n >= PATH_MAX) {
		LOG_WA("Could not create path, rootpath > PATH_MAX");
		mldh_rc = -1;
		goto done;
	}
	char *rootpp = mpath;
	while (*rootpp == '/') rootpp++; /* Remove preceding '/' */
	while (mpath[strlen(mpath)-1] == '/') { /* Remove trailing '/' if needed */
		mpath[strlen(mpath)-1] = '\0';
	}

	/*
	 * Add relative path. Shall end with '/'
	 * Example: ro1/ro2/ro3/re1/re2/re3/
	 * Check that not > PATH_MAX
	 */
	if (relpath[strlen(relpath)-1] != '/') {
		n = snprintf(dir_to_make, PATH_MAX, "/%s/%s/", rootpp, relpath);
	} else {
		n = snprintf(dir_to_make, PATH_MAX, "/%s/%s", rootpp, relpath);
	}
	if (n >= PATH_MAX) {
		LOG_WA("Could not create path > PATH_MAX");
		mldh_rc = -1;
		goto done;
	}
	TRACE("%s - Path to create \"%s\"",__FUNCTION__,dir_to_make);
		
	/* Create the path */
	int path_len = 0;
	spath_p = epath_p = dir_to_make;
	while ((epath_p = strchr(epath_p, '/')) != NULL) {
		if (epath_p == spath_p) {
			epath_p++;
			continue; /* Don't try to create path "/" */
		}
		epath_p++;
		path_len = epath_p - spath_p;
		strncpy(mpath, spath_p, path_len);
		mpath[path_len] = '\0';
		rc = mkdir(mpath, S_IRWXU | S_IRWXG | S_IRWXO);
		if ((rc != 0) && (errno != EEXIST)) {
			LOG_ER("Making directory error %s",strerror(errno));
			mldh_rc = -1;
			goto done;
		}
	}
	TRACE("%s - Dir \"%s\" created",__FUNCTION__, mpath);
	
done:
	TRACE_LEAVE2("mldh_rc = %u", mldh_rc);
	return mldh_rc;
}
コード例 #24
0
/**
 * Return number of log files in a dir and the name of the oldest file.
 * @param indata, see gnolfh_in_t
 * @param outdata, char *oldest_file
 * @param max_outsize, Max size for oldest_file string
 * 
 * @return int, number of logfiles or -1 if error
 */
int get_number_of_log_files_hdl(void *indata, void *outdata, size_t max_outsize)
{
	struct dirent **namelist;
	int n, old_date = -1, old_time = -1, old_ind = -1, files, i, failed = 0;
	char path[PATH_MAX];
	gnolfh_in_t *params_in;
	char *oldest_file;
	int rc = 0;
	
	TRACE_ENTER();
	
	params_in = (gnolfh_in_t *) indata;
	oldest_file = (char *) outdata;
	
	/* Initialize the filter */
	n = snprintf(file_prefix, SA_MAX_NAME_LENGTH, "%s", params_in->file_name);
	if (n >= SA_MAX_NAME_LENGTH) {
		rc = -1;
		LOG_WA("file_prefix > SA_MAX_NAME_LENGTH");
		goto done_exit;
	}

	n = snprintf(path, PATH_MAX, "%s/%s",
			params_in->logsv_root_dir, params_in->pathName);
	if (n >= PATH_MAX) {
		LOG_WA("path > PATH_MAX");
		rc = -1;
		goto done_exit;
	}

	files = n = scandir(path, &namelist, filter_func, alphasort);
	if (n == -1 && errno == ENOENT) {
		rc = 0;
		goto done_exit;
	}

	if (n < 0) {
		LOG_WA("scandir:%s - %s", strerror(errno), path);
		rc = -1;
		goto done_exit;
	}
	
	if (n == 0) {
		rc = files;
		goto done_exit;
	}

	while (n--) {
		TRACE_3("%s", namelist[n]->d_name);
		if (check_oldest(namelist[n]->d_name, params_in->file_name,
				 strlen(params_in->file_name), &old_date, &old_time)) {
			old_ind = n;
		} else {
			failed++;	/* wrong format */
		}
	}
	if (old_ind != -1) {
		TRACE_1("oldest: %s", namelist[old_ind]->d_name);
		n = snprintf(oldest_file, max_outsize, "%s/%s",
				path, namelist[old_ind]->d_name);
		if (n >= max_outsize) {
			LOG_WA("oldest_file > max_outsize");
			rc = -1;
			goto done_free;
		} else {
			rc = (files - failed);
		}
	} else {
		TRACE("Only file/files with wrong format found");
	}

done_free:
	/* Free scandir allocated memory */
	for (i = 0; i < files; i++)
		free(namelist[i]);
	free(namelist);

done_exit:	
	TRACE_LEAVE();
	return rc;
}
コード例 #25
0
/****************************************************************************\
 * Function: avsv_validate_reo_type_in_csync
 *
 * Purpose:  Vaidate reo_type received during cold sync updates. Return success,
 *           if cold sync is over for this reo_type. Return failure if standby
 *           is still to get cold sync for this reo_type.
 *
 * Input: cb - AVD CB pointer.
 *        reo_type - reo type need to be validated during cold sync.
 *
 * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
 *
 * NOTES:
 *
 * 
\**************************************************************************/
static uns32 avsv_validate_reo_type_in_csync(AVD_CL_CB *cb, uns32 reo_type)
{
	uns32 status = NCSCC_RC_FAILURE;

	switch (reo_type) {
	case AVSV_CKPT_AVD_CB_CONFIG:
		if (cb->synced_reo_type >= AVSV_CKPT_AVD_CB_CONFIG)
			status = NCSCC_RC_SUCCESS;
		break;

		/* AVND Async Update messages */
	case AVSV_CKPT_AVD_NODE_CONFIG:
	case AVSV_CKPT_AVND_NODE_UP_INFO:
	case AVSV_CKPT_AVND_ADMIN_STATE:
	case AVSV_CKPT_AVND_OPER_STATE:
	case AVSV_CKPT_AVND_NODE_STATE:
	case AVSV_CKPT_AVND_RCV_MSG_ID:
	case AVSV_CKPT_AVND_SND_MSG_ID:
		if (cb->synced_reo_type >= AVSV_CKPT_AVD_NODE_CONFIG)
			status = NCSCC_RC_SUCCESS;
		break;

	case AVSV_CKPT_AVD_APP_CONFIG:
		if (cb->synced_reo_type >= AVSV_CKPT_AVD_APP_CONFIG)
			status = NCSCC_RC_SUCCESS;
		break;

		/* SG Async Update messages */
	case AVSV_CKPT_AVD_SG_CONFIG:
	case AVSV_CKPT_SG_ADMIN_STATE:
	case AVSV_CKPT_SG_ADJUST_STATE:
	case AVSV_CKPT_SG_SU_ASSIGNED_NUM:
	case AVSV_CKPT_SG_SU_SPARE_NUM:
	case AVSV_CKPT_SG_SU_UNINST_NUM:
	case AVSV_CKPT_SG_FSM_STATE:
		if (cb->synced_reo_type >= AVSV_CKPT_AVD_SG_CONFIG)
			status = NCSCC_RC_SUCCESS;
		break;

		/* SU Async Update messages */
	case AVSV_CKPT_AVD_SU_CONFIG:
	case AVSV_CKPT_SU_SI_CURR_ACTIVE:
	case AVSV_CKPT_SU_SI_CURR_STBY:
	case AVSV_CKPT_SU_ADMIN_STATE:
	case AVSV_CKPT_SU_TERM_STATE:
	case AVSV_CKPT_SU_SWITCH:
	case AVSV_CKPT_SU_OPER_STATE:
	case AVSV_CKPT_SU_PRES_STATE:
	case AVSV_CKPT_SU_READINESS_STATE:
	case AVSV_CKPT_SU_ACT_STATE:
	case AVSV_CKPT_SU_PREINSTAN:
		if (cb->synced_reo_type >= AVSV_CKPT_AVD_SU_CONFIG)
			status = NCSCC_RC_SUCCESS;
		break;

		/* SI Async Update messages */
	case AVSV_CKPT_AVD_SI_CONFIG:
	case AVSV_CKPT_SI_SU_CURR_ACTIVE:
	case AVSV_CKPT_SI_SU_CURR_STBY:
	case AVSV_CKPT_SI_SWITCH:
	case AVSV_CKPT_SI_ASSIGNMENT_STATE:
	case AVSV_CKPT_SI_ADMIN_STATE:
	case AVSV_CKPT_SI_ALARM_SENT:
		if (cb->synced_reo_type >= AVSV_CKPT_AVD_SI_CONFIG)
			status = NCSCC_RC_SUCCESS;
		break;

	case AVSV_CKPT_AVD_SG_OPER_SU:
		if (cb->synced_reo_type >= AVSV_CKPT_AVD_SG_OPER_SU)
			status = NCSCC_RC_SUCCESS;
		break;

	case AVSV_CKPT_AVD_SG_ADMIN_SI:
		if (cb->synced_reo_type >= AVSV_CKPT_AVD_SG_ADMIN_SI)
			status = NCSCC_RC_SUCCESS;
		break;

		/* COMP Async Update messages */
	case AVSV_CKPT_AVD_COMP_CONFIG:
	case AVSV_CKPT_COMP_CURR_PROXY_NAME:
	case AVSV_CKPT_COMP_CURR_NUM_CSI_ACTV:
	case AVSV_CKPT_COMP_CURR_NUM_CSI_STBY:
	case AVSV_CKPT_COMP_OPER_STATE:
	case AVSV_CKPT_COMP_READINESS_STATE:
	case AVSV_CKPT_COMP_PRES_STATE:
	case AVSV_CKPT_COMP_RESTART_COUNT:
		if (cb->synced_reo_type >= AVSV_CKPT_AVD_COMP_CONFIG)
			status = NCSCC_RC_SUCCESS;
		break;
	case AVSV_CKPT_AVD_SI_ASS:
		if (cb->synced_reo_type >= AVSV_CKPT_AVD_SI_ASS)
			status = NCSCC_RC_SUCCESS;
		break;

	case AVSV_CKPT_AVD_SI_TRANS:
		if (cb->synced_reo_type >= AVSV_CKPT_AVD_SI_TRANS)
			status = NCSCC_RC_SUCCESS;
		break;

	case AVSV_CKPT_AVD_COMP_CS_TYPE_CONFIG:
		if (cb->synced_reo_type >= AVSV_CKPT_AVD_COMP_CS_TYPE_CONFIG)
			status = NCSCC_RC_SUCCESS;
		break;
	default:
		LOG_WA("%s: unknown type %u", __FUNCTION__, reo_type);

	}
	return status;
}
コード例 #26
0
/**
 * read the configuartion file
 *
 * @param config dtm_config_file
 *
 * @return NCSCC_RC_SUCCESS
 * @return NCSCC_RC_FAILURE
 *
 */
int dtm_read_config(DTM_INTERNODE_CB * config, char *dtm_config_file)
{
	FILE *dtm_conf_file;
	char line[DTM_MAX_TAG_LEN];
	int i, n, comment_line, fieldmissing = 0, tag = 0, tag_len = 0;
	/* Location for storing the matched IP address */
	char *local_match_ip = NULL;
	FILE *fp;

	TRACE_ENTER();

	/*
	 * Initialize the socket timeout values in case they are not
	 * set in the dtm.conf file
	 */

	memset(line, 0, DTM_MAX_TAG_LEN);

	config->so_keepalive = SOCK_KEEPALIVE;
	config->comm_keepidle_time = KEEPIDLE_TIME;
	config->comm_keepalive_intvl = KEEPALIVE_INTVL;
	config->comm_keepalive_probes = KEEPALIVE_PROBES;
	config->i_addr_family = DTM_IP_ADDR_TYPE_IPV4;
	config->bcast_msg_freq = BCAST_FRE;
	config->initial_dis_timeout = DIS_TIME_OUT;
	config->sock_sndbuf_size = 0;
	config->sock_rcvbuf_size = 0;
	config->mcast_flag = false;
	config->scope_link = false;
	config->node_id = m_NCS_GET_NODE_ID;
	intranode_max_processes = 100;
	fp = fopen(PKGSYSCONFDIR "/node_name", "r");
	if (fp == NULL) {
		LOG_ER("DTM: Could not open file  node_name ");
		return errno;
	}
	if (EOF == fscanf(fp, "%s", config->node_name)) {
		fclose(fp);
		LOG_ER("DTM: Could not get node name ");
		return errno;
	}
	fclose(fp);
	TRACE("DTM :config->node_nam : %s", config->node_name);
	config->cluster_id = -1;

	/* 
	 * Set timeout to a negative value so we can detect if the value 
	 * is missing in the conf file
	 */

	/* Open dtm.conf config file. */
	dtm_conf_file = fopen(dtm_config_file, "r");
	if (dtm_conf_file == NULL) {
		/* Problem with conf file - return errno value */
		LOG_ER("DTM: dtm_read_cofig: there was a problem opening the dtm.conf file");
		return errno;
	}

	/* Read file. */
	while (fgets(line, DTM_MAX_TAG_LEN, dtm_conf_file)) {
		/* If blank line, skip it - and set tag back to 0. */
		if (strcmp(line, "\n") == 0) {
			tag = 0;
			continue;
		}

		/* If a comment line, skip it. */
		n = strlen(line);
		comment_line = 0;
		for (i = 0; i < n; i++) {
			if ((line[i] == ' ') || (line[i] == '\t'))
				continue;
			else if (line[i] == '#') {
				comment_line = 1;
				break;
			} else
				break;
		}
		if (comment_line)
			continue;

		/* Remove the new-line char at the end of the line. */
		line[n - 1] = 0;

		/* Set tag if we are not in a tag. */
		if ((tag == 0) || (strncmp(line, "DTM_", 4) == 0)) {

			if (strncmp(line, "DTM_CLUSTER_ID=", strlen("DTM_CLUSTER_ID=")) == 0) {
				tag_len = strlen("DTM_CLUSTER_ID=");
				config->cluster_id = atoi(&line[tag_len]);
				if (config->cluster_id < 1) {
					LOG_ER("DTM:cluster_id must be a positive integer");
					return -1;
				}
				tag = 0;
				tag_len = 0;

			}
			if (strncmp(line, "DTM_NODE_IP=", strlen("DTM_NODE_IP=")) == 0) {
				tag_len = strlen("DTM_NODE_IP=");
				strncpy(config->ip_addr, &line[tag_len], INET6_ADDRSTRLEN - 1);	/* ipv4 ipv6 addrBuffer */
				if (strlen(config->ip_addr) == 0) {
					LOG_ER("DTM:ip_addr Shouldn't  be NULL");
					return -1;
				}

				tag = 0;
				tag_len = 0;

			}

			if (strncmp(line, "DTM_MCAST_ADDR=", strlen("DTM_MCAST_ADDR=")) == 0) {
				tag_len = strlen("DTM_MCAST_ADDR=");
				strncpy(config->mcast_addr, &line[tag_len], INET6_ADDRSTRLEN - 1);	/* ipv4 ipv6 addrBuffer */
				if (strlen(config->mcast_addr) != 0) {
					config->mcast_flag = true;
				}

				tag = 0;
				tag_len = 0;

			}
			if (strncmp(line, "DTM_TCP_LISTENING_PORT=", strlen("DTM_TCP_LISTENING_PORT=")) == 0) {
				tag_len = strlen("DTM_TCP_LISTENING_PORT=");
				config->stream_port = (in_port_t)atoi(&line[tag_len]);

				if (config->stream_port < 1) {
					LOG_ER("DTM:stream_port  must be a positive integer");
					return -1;
				}

				tag = 0;
				tag_len = 0;

			}
			if (strncmp(line, "DTM_UDP_BCAST_SND_PORT=", strlen("DTM_UDP_BCAST_SND_PORT=")) == 0) {
				tag_len = strlen("DTM_UDP_BCAST_SND_PORT=");
				config->dgram_port_sndr = ((in_port_t)atoi(&line[tag_len]));
				if (config->dgram_port_sndr < 1) {
					LOG_ER("DTM:dgram_port_sndr  must be a positive integer");
					return -1;
				}

				tag = 0;
				tag_len = 0;

			}
			if (strncmp(line, "DTM_UDP_BCAST_REV_PORT=", strlen("DTM_UDP_BCAST_REV_PORT=")) == 0) {
				tag_len = strlen("DTM_UDP_BCAST_REV_PORT=");
				config->dgram_port_rcvr = ((in_port_t)atoi(&line[tag_len]));
				TRACE("DTM:dgram_port_rcvr  :%d", config->dgram_port_rcvr);
				if (config->dgram_port_rcvr < 1) {
					LOG_ER("DTM:dgram_port_rcvr t must be a positive integer");
					return -1;
				}

				tag = 0;
				tag_len = 0;

			}
			if (strncmp(line, "DTM_BCAST_FRE_MSECS=", strlen("DTM_BCAST_FRE_MSECS=")) == 0) {
				tag_len = strlen("DTM_BCAST_FRE_MSECS=");
				config->bcast_msg_freq = atoi(&line[tag_len]);
				if (config->bcast_msg_freq < 1) {
					LOG_ER("DTM:bcast_msg_freq  must be a positive integer");
					return -1;
				}

				tag = 0;
				tag_len = 0;

			}
			if (strncmp(line, "DTM_INI_DIS_TIMEOUT_SECS=", strlen("DTM_INI_DIS_TIMEOUT_SECS=")) == 0) {
				tag_len = strlen("DTM_INI_DIS_TIMEOUT_SECS=");
				config->initial_dis_timeout = atoi(&line[tag_len]);
				if (config->initial_dis_timeout < 1) {
					LOG_ER("DTM:initial_dis_timeout must be a positive integer");
					return -1;
				}

				tag = 0;
				tag_len = 0;

			}
			if (strncmp(line, "DTM_SKEEPALIVE=", strlen("DTM_SKEEPALIVE=")) == 0) {
				tag_len = strlen("DTM_SKEEPALIVE=");
				config->so_keepalive = atoi(&line[tag_len]);
				if (config->so_keepalive < 0 || config->so_keepalive > 1) {
					LOG_ER("DTM: so_keepalive needs to be 0 or 1");
					return -1;
				}

				tag = 0;
				tag_len = 0;

			}
			if (strncmp(line, "DTM_TCP_KEEPIDLE_TIME=", strlen("DTM_TCP_KEEPIDLE_TIME=")) == 0) {
				tag_len = strlen("DTM_TCP_KEEPIDLE_TIME=");
				config->comm_keepidle_time = atoi(&line[tag_len]);
				if (config->comm_keepidle_time < 1) {
					LOG_ER("DTM:comm_keepidle_time must be a positive integer");
					return -1;
				}

				tag = 0;
				tag_len = 0;

			}
			if (strncmp(line, "DTM_TCP_KEEPALIVE_INTVL=", strlen("DTM_TCP_KEEPALIVE_INTVL=")) == 0) {
				tag_len = strlen("DTM_TCP_KEEPALIVE_INTVL=");
				config->comm_keepalive_intvl = atoi(&line[tag_len]);
				if (config->comm_keepalive_intvl < 1) {
					LOG_ER("DTM:comm_keepalive_intvl must be a positive integer");
					return -1;
				}

				tag = 0;
				tag_len = 0;

			}
			if (strncmp(line, "DTM_TCP_KEEPALIVE_PROBES=", strlen("DTM_TCP_KEEPALIVE_PROBES=")) == 0) {
				tag_len = strlen("DTM_TCP_KEEPALIVE_PROBES=");
				config->comm_keepalive_probes = atoi(&line[tag_len]);
				if (config->comm_keepalive_probes < 1) {
					LOG_ER("DTM:comm_keepalive_probes must be a positive integer");
					return -1;
				}

				tag = 0;
				tag_len = 0;

			}
			if (strncmp(line, "DTM_SOCK_SND_RCV_BUF_SIZE=", strlen("DTM_SOCK_SND_RCV_BUF_SIZE=")) == 0) {
				tag_len = strlen("DTM_SOCK_SND_RCV_BUF_SIZE=");
				uint32_t sndbuf_size = 0; /* Send buffer size */
				uint32_t rcvbuf_size = 0;  /* Receive buffer size */
				socklen_t optlen; /* Option length */
				int sockfd;
				sockfd = socket(AF_INET, SOCK_STREAM, 0);
				optlen = sizeof(rcvbuf_size);
				getsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &rcvbuf_size, &optlen);
				if ((rcvbuf_size < DTM_SOCK_SND_RCV_BUF_SIZE) && (atoi(&line[tag_len]) < DTM_SOCK_SND_RCV_BUF_SIZE)) {
					config->sock_rcvbuf_size = DTM_SOCK_SND_RCV_BUF_SIZE;
				} else if (atoi(&line[tag_len]) > rcvbuf_size) {
					config->sock_rcvbuf_size = atoi(&line[tag_len]);
				}  

				optlen = sizeof(sndbuf_size);
				getsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &sndbuf_size, &optlen);
				if ((sndbuf_size < DTM_SOCK_SND_RCV_BUF_SIZE) && (atoi(&line[tag_len]) < DTM_SOCK_SND_RCV_BUF_SIZE)){
					config->sock_sndbuf_size = DTM_SOCK_SND_RCV_BUF_SIZE;
				} else if (atoi(&line[tag_len]) > sndbuf_size) {
					config->sock_sndbuf_size = atoi(&line[tag_len]);
				}  

				tag = 0;
				tag_len = 0;
			}
			if (strncmp(line, "DTM_INTRANODE_MAX_PROCESSES=", strlen("DTM_INTRANODE_MAX_PROCESSES=")) == 0) {
				tag_len = strlen("DTM_INTRANODE_MAX_PROCESSES=");
				intranode_max_processes = atoi(&line[tag_len]);
				if (intranode_max_processes < 100) {
					LOG_WA("DTM: intranode_max_processes must be higher than 100, setting it to default");
					intranode_max_processes = 100;
				}
				tag = 0;
				tag_len = 0;
			}

		}

		memset(line, 0, DTM_MAX_TAG_LEN);
	}

	/* End-of-file or error? */
	int err = feof(dtm_conf_file) ? 0 : errno;

	/* Close file. */
	fclose(dtm_conf_file);

	/*************************************************************/
	/* Set up validate the IP & sa_family stuff  */
	/*************************************************************/
	local_match_ip = dtm_validate_listening_ip_addr(config);
	if (local_match_ip == NULL) {
		LOG_ER("DTM: ip_addr cannot match available network interfaces with IPs of node specified in the dtm.conf file");
		return -1;
	}

	/* Test so we have all mandatory fields */
	if ((config->cluster_id) == 0) {
		LOG_ER("DTM: dtm_read_config: cluster_id is missing in conf file");
		fieldmissing = 1;
	} else if ((config->node_id) == 0) {
		LOG_ER("DTM: dtm_read_config: node_id is missing in configuration");
		fieldmissing = 1;
	} else if ((config->dgram_port_sndr) == 0) {
		LOG_ER("DTM: dtm_read_config: dgram_port_sndr is missing in conf file");
		fieldmissing = 1;
	} else if ((config->dgram_port_rcvr) == 0) {
		LOG_ER("DTM: dtm_read_config: dgram_port_rcvr is missing in conf file");
		fieldmissing = 1;
	} else if ((config->stream_port) == 0) {
		LOG_ER("DTM: dtm_read_config: stream_port is missing in conf file");
		fieldmissing = 1;
	} else if (strlen(config->ip_addr) == 0) {
		LOG_ER("DTM: dtm_read_config: ip_addr is missing in conf file");
		fieldmissing = 1;
	} else if (strlen(config->node_name) == 0) {
		LOG_ER("DTM: dtm_read_config: node_name is missing in conf file");
		fieldmissing = 1;
	}

	if (fieldmissing == 1)
		return -1;
	/* All done. */

	dtm_print_config(config);

	TRACE_LEAVE();
	return (err);
}
コード例 #27
0
ファイル: mqd_evt.c プロジェクト: helioloureiro/opensaf-fork
static void mqd_dump_obj_node(MQD_OBJ_NODE *qnode)
{
	NCS_Q_ITR itr;
	MQD_TRACK_OBJ *pTrack = 0;
	MQD_OBJECT_ELEM *pilist = 0;
	if (qnode == NULL) {
		LOG_WA("MQD_OBJ_NODE is NULL");
		return;
	}
	TRACE(" The Qnode value is : %p ", qnode);
	TRACE(" The Qnode Ohjinfo pointer value is : %p ", &(qnode->oinfo));
	if (qnode->oinfo.type == MQSV_OBJ_QGROUP) {
		TRACE("Queue Group Name is : %s", qnode->oinfo.name.value);
		switch (qnode->oinfo.info.qgrp.policy) {
		case SA_MSG_QUEUE_GROUP_ROUND_ROBIN:
			TRACE("Policy is :Round Robin");
			break;
		case SA_MSG_QUEUE_GROUP_LOCAL_ROUND_ROBIN:
			TRACE("Policy is :Local Round Robin");
			break;
		case SA_MSG_QUEUE_GROUP_LOCAL_BEST_QUEUE:
			TRACE("Policy is :Local Best Queue");
			break;
		case SA_MSG_QUEUE_GROUP_BROADCAST:
			TRACE("Policy is :Group Broadcast");
			break;
		default:
			TRACE("Policy is :Unknown");
		}
	} else if (qnode->oinfo.type == MQSV_OBJ_QUEUE) {
		TRACE("Queue Name is : %s", qnode->oinfo.name.value);
		if (qnode->oinfo.info.q.send_state == MSG_QUEUE_AVAILABLE)
			TRACE("The sending state is : MSG_QUEUE_AVAILABLE ");
		else if (qnode->oinfo.info.q.send_state == MSG_QUEUE_UNAVAILABLE)
			TRACE("The sending state is : MSG_QUEUE_UNAVAILABLE ");
		TRACE(" Retention Time is : %llu ", qnode->oinfo.info.q.retentionTime);
		TRACE(" MDS Destination is : %" PRIu64, qnode->oinfo.info.q.dest);
		TRACE(" Node id from the MDS Destination of the queue is :%u ",
			m_NCS_NODE_ID_FROM_MDS_DEST(qnode->oinfo.info.q.dest));
		switch (qnode->oinfo.info.q.owner) {
		case MQSV_QUEUE_OWN_STATE_ORPHAN:
			TRACE(" Ownership is: MQSV_QUEUE_OWN_STATE_ORPHAN ");
			break;
		case MQSV_QUEUE_OWN_STATE_OWNED:
			TRACE(" Owner ship is: MQSV_QUEUE_OWN_STATE_OWNED");
			break;
		case MQSV_QUEUE_OWN_STATE_PROGRESS:
			TRACE(" Owner ship is:MQSV_QUEUE_OWN_STATE_PROGRESS");
			break;
		default:
			TRACE(" Owner ship is:Unknown ");
		}
		TRACE(" Queue Handle is : %u", qnode->oinfo.info.q.hdl);
		if (qnode->oinfo.info.q.adv)
			TRACE(" Advertisement flag is set ");
		else
			TRACE(" Advertisement flag is not set ");
		TRACE(" Is mqnd down for this queue is :%d ", qnode->oinfo.info.q.is_mqnd_down);
		TRACE(" Creation time for this queue is :%llu ", qnode->oinfo.creationTime);
	}
	TRACE(" *********************Printing the ilist******************* ");
	memset(&itr, 0, sizeof(NCS_Q_ITR));
	itr.state = 0;
	while ((pilist = (MQD_OBJECT_ELEM *)ncs_walk_items(&qnode->oinfo.ilist, &itr))) {
		TRACE(" The ilist member pointer value is: %p ", pilist->pObject);
		TRACE(" The ilist member Name is : %s ", pilist->pObject->name.value);
	}
	TRACE("********** End of the ilist************* ");
	TRACE("********** Printing the track list************* ");
	memset(&itr, 0, sizeof(NCS_Q_ITR));
	itr.state = 0;
	while ((pTrack = (MQD_TRACK_OBJ *)ncs_walk_items(&qnode->oinfo.tlist, &itr))) {
		TRACE(" To service is :%u ", pTrack->to_svc);
		TRACE(" The MDSdest destination of the track subscibed element is: %" PRIu64, pTrack->dest);
		TRACE(" The Nodeid from MDSdest of the track subscibed element is: %u ",
			m_NCS_NODE_ID_FROM_MDS_DEST(pTrack->dest));
	}
	TRACE("********** End of the track list************* ");

}
コード例 #28
0
ファイル: immd_amf.c プロジェクト: indonexia2004/opensaf-indo
/****************************************************************************\
 PROCEDURE NAME : immd_saf_csi_set_cb
 
 DESCRIPTION    : This is a SAF callback function which will be called 
                  when there is any change in the HA state.
 
 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.
                 haState        - The new HA state to be assumeb by the 
                                  component service instance identified by 
                                  csiName.
                 csiDescriptor  - 

 RETURNS       : Nothing.
\*****************************************************************************/
static void immd_saf_csi_set_cb(SaInvocationT invocation,
				const SaNameT *compName, SaAmfHAStateT new_haState, SaAmfCSIDescriptorT csiDescriptor)
{
	SaAisErrorT error = SA_AIS_OK;
	SaAmfHAStateT prev_ha_state;
	bool role_change = true;
	uint32_t rc = NCSCC_RC_SUCCESS;
	IMMD_CB *cb = immd_cb;

	TRACE_ENTER();

	prev_ha_state = cb->ha_state;

	/* Invoke the appropriate state handler routine */
	switch (new_haState) {
	case SA_AMF_HA_ACTIVE:
		error = amf_active_state_handler(cb, invocation);
		break;
	case SA_AMF_HA_STANDBY:
		error = amf_standby_state_handler(cb, invocation);
		break;
	case SA_AMF_HA_QUIESCED:
		/* switch over */
		error = amf_quiesced_state_handler(cb, invocation);
		break;
	case SA_AMF_HA_QUIESCING:
		/* shut down */
		error = amf_quiescing_state_handler(cb, invocation);
		break;
	default:
		LOG_WA("invalid state: %d ", new_haState);
		error = SA_AIS_ERR_FAILED_OPERATION;
		break;
	}

	if (error != SA_AIS_OK)
		goto response;

	if (new_haState == SA_AMF_HA_QUIESCED) {
		/*Note: should we not change state in cb->ha_state here.
		   This is done in immd_mds_quiesced_ack_process */
		goto done;
	}

	/* Update control block */
	cb->ha_state = new_haState;

	TRACE_5("New-state: %s, prev-state: %s", ha_state_name(new_haState), ha_state_name(prev_ha_state));

	/* Handle active to active role change. */
	if (prev_ha_state == new_haState) {
		TRACE_5("No role change!");	/* bug? */
		role_change = false;
	}

	if (role_change) {
		if ((rc = immd_mds_change_role(cb)) != NCSCC_RC_SUCCESS) {
			LOG_WA("immd_mds_change_role FAILED");
			error = SA_AIS_ERR_FAILED_OPERATION;
			goto response;
		}

		TRACE_5("Inform MBCSV of HA state change to %s",
			(new_haState == SA_AMF_HA_ACTIVE) ? "ACTIVE" : "STANDBY");

		if (immd_mbcsv_chgrole(cb) != NCSCC_RC_SUCCESS) {
			LOG_WA("immd_mbcsv_chgrole FAILED");
			error = SA_AIS_ERR_FAILED_OPERATION;
			goto response;
		}

		if (new_haState == SA_AMF_HA_ACTIVE) {
			/* Change of role to active => We may need to elect new coord */
			if(immd_cb->m2PbeCanLoad) {
				LOG_IN("Electing coord in immd_saf_csi_set_cb() to ACTIVE");
				immd_proc_elect_coord(cb, true);
			}
			immd_db_purge_fevs(cb);
		}
	}

 response:
	saAmfResponse(cb->amf_hdl, invocation, error);
 done:
	TRACE_LEAVE();
}
コード例 #29
0
uint32_t immnd_mds_register(IMMND_CB *cb)
{
	uint32_t rc = NCSCC_RC_SUCCESS;
	NCSMDS_INFO svc_info;
	MDS_SVC_ID svc_id[1] = { NCSMDS_SVC_ID_IMMD };
	/*NCS_PHY_SLOT_ID phy_slot; */
	TRACE_ENTER();

	/* STEP1: Get the MDS Handle */
	rc = immnd_mds_get_handle(cb);

	if (rc != NCSCC_RC_SUCCESS)
		return rc;

	/* memset the svc_info */
	memset(&svc_info, 0, sizeof(NCSMDS_INFO));

	/* STEP 2 : Install on ADEST with MDS with service ID NCSMDS_SVC_ID_IMMND. */
	svc_info.i_mds_hdl = cb->immnd_mds_hdl;
	svc_info.i_svc_id = NCSMDS_SVC_ID_IMMND;
	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;
	svc_info.info.svc_install.i_svc_cb = immnd_mds_callback;	/* callback */
	svc_info.info.svc_install.i_mds_q_ownership = false;
	svc_info.info.svc_install.i_mds_svc_pvt_ver = IMMND_MDS_PVT_SUBPART_VERSION;

	if (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) {
		LOG_WA("MDS Install Failed");
		return NCSCC_RC_FAILURE;
	}
	cb->immnd_mdest_id = svc_info.info.svc_install.o_dest;

	/* STEP 3: Subscribe to IMMD up/down events */
	svc_info.i_op = MDS_SUBSCRIBE; /* Normal mode subscription => vdest is used. */
	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_WA("MDS Subscription Failed");
		goto error1;
	}

	/* STEP 4: Subscribe to IMMA_OM up/down events */
	svc_id[0] = NCSMDS_SVC_ID_IMMA_OM;
	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 (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) {
		LOG_WA("MDS Subscription Failed");
		goto error1;
	}

	/* STEP 5: Subscribe to IMMA_OI up/down events */
	svc_id[0] = NCSMDS_SVC_ID_IMMA_OI;
	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 (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) {
		LOG_WA("MDS Subscription Failed");
		goto error1;
	}

	cb->node_id = m_NCS_GET_NODE_ID;
	TRACE_2("cb->node_id:%x", cb->node_id);

	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
 error1:

	/* Uninstall with the mds */
	immnd_mds_unregister(cb);
	TRACE_LEAVE();
	return NCSCC_RC_FAILURE;
}