Beispiel #1
0
/****************************************************************************
  Name          : eda_hdl_cbk_dispatch_one
 
  Description   : This routine dispatches one pending callback.
 
  Arguments     : cb      - ptr to the EDA control block
                  hdl_rec - ptr to the handle record
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
static uns32 eda_hdl_cbk_dispatch_one(EDA_CB *cb, EDA_CLIENT_HDL_REC *hdl_rec)
{
	EDSV_MSG *cbk_msg = NULL;
	uns32 rc = SA_AIS_OK;

	/* Nonblk receive to obtain the message from priority queue */
	while (NULL != (cbk_msg = (EDSV_MSG *)
			m_NCS_IPC_NON_BLK_RECEIVE(&hdl_rec->mbx, cbk_msg))) {
		if (cbk_msg->info.cbk_info.type == EDSV_EDS_DELIVER_EVENT) {
			if (eda_find_subsc_validity(cb, cbk_msg) == NCSCC_RC_SUCCESS) {
				/* process the callback list record */
				eda_hdl_cbk_rec_prc(cb, cbk_msg, &hdl_rec->reg_cbk);
				eda_msg_destroy(cbk_msg);
				break;
			}
			eda_msg_destroy(cbk_msg);
		} else {
			/* process the callback list record */
			eda_hdl_cbk_rec_prc(cb, cbk_msg, &hdl_rec->reg_cbk);
			eda_msg_destroy(cbk_msg);
			break;
		}
	}
	return rc;
}
Beispiel #2
0
/****************************************************************************
  Name          : eda_hdl_cbk_dispatch_block
 
  Description   : This routine blocks forever for receiving indications from 
                  EDS. The routine returns when saEvtFinalize is executed on 
                  the handle.
 
  Arguments     : cb      - ptr to the EDA control block
                  hdl_rec - ptr to the handle record
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
static uns32 eda_hdl_cbk_dispatch_block(EDA_CB *cb, EDA_CLIENT_HDL_REC *hdl_rec)
{
	EDSV_MSG *cbk_msg = NULL;
	uns32 rc = SA_AIS_OK;

	for (;;) {
		if (NULL != (cbk_msg = (EDSV_MSG *)
			     m_NCS_IPC_RECEIVE(&hdl_rec->mbx, cbk_msg))) {
			if (cbk_msg->info.cbk_info.type == EDSV_EDS_DELIVER_EVENT) {
				if (eda_find_subsc_validity(cb, cbk_msg) == NCSCC_RC_SUCCESS) {
					/* process the callback list record */
					eda_hdl_cbk_rec_prc(cb, cbk_msg, &hdl_rec->reg_cbk);
				}
			} else {
				/* process the callback list record */
				eda_hdl_cbk_rec_prc(cb, cbk_msg, &hdl_rec->reg_cbk);
			}

			/* now that we are done with this rec, free the resources */
			eda_msg_destroy(cbk_msg);
			/* check to see the validity of the hdl. */
			if (FALSE == eda_validate_eda_client_hdl(cb, hdl_rec))
				return rc;
		} else
			return rc;	/* FIX to handle finalize clean up of mbx */
	}

	return rc;
}
Beispiel #3
0
/****************************************************************************
 * Name          : eda_clear_mbx
 *
 * Description   : This is the function which deletes all the messages from 
 *                 the mail box.
 *
 * Arguments     : arg     - argument to be passed.
 *                 msg     - Event start pointer.
 *
 * Return Values : TRUE/FALSE
 *
 * Notes         : None.
 *****************************************************************************/
NCS_BOOL eda_clear_mbx(NCSCONTEXT arg, NCSCONTEXT msg)
{
	EDSV_MSG *cbk, *pnext;

	pnext = cbk = (EDSV_MSG *)msg;
	while (pnext) {
		pnext = cbk->next;
		eda_msg_destroy(cbk);
		cbk = pnext;
	}
	return TRUE;
}
Beispiel #4
0
/****************************************************************************
  Name          : eda_hdl_cbk_dispatch_all
 
  Description   : This routine dispatches all the pending callbacks.
 
  Arguments     : cb      - ptr to the EDA control block
                  hdl_rec - ptr to the handle record
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
static uns32 eda_hdl_cbk_dispatch_all(EDA_CB *cb, EDA_CLIENT_HDL_REC *hdl_rec)
{
	EDSV_MSG *cbk_msg = NULL;
	uns32 rc = SA_AIS_OK;

	/* Recv all the cbk notifications from the queue & process them */
	do {
		if (NULL == (cbk_msg = (EDSV_MSG *)m_NCS_IPC_NON_BLK_RECEIVE(&hdl_rec->mbx, cbk_msg)))
			break;
		if (cbk_msg->info.cbk_info.type == EDSV_EDS_DELIVER_EVENT) {
			if (eda_find_subsc_validity(cb, cbk_msg) == NCSCC_RC_SUCCESS) {
				/* process the callback list record */
				eda_hdl_cbk_rec_prc(cb, cbk_msg, &hdl_rec->reg_cbk);
			}
		} else {
			/* process the callback list record */
			eda_hdl_cbk_rec_prc(cb, cbk_msg, &hdl_rec->reg_cbk);
		}
		/* now that we are done with this rec, free the resources */
		eda_msg_destroy(cbk_msg);
	} while (1);

	return rc;
}
Beispiel #5
0
/****************************************************************************
  Name          : eda_eds_msg_proc
 
  Description   : This routine is used to process the ASYNC incoming
                  EDS messages. 
 
  Arguments     : pointer to struct ncsmds_callback_info
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
static uint32_t eda_eds_msg_proc(EDA_CB *eda_cb, EDSV_MSG *edsv_msg, MDS_SEND_PRIORITY_TYPE prio)
{

	switch (edsv_msg->type) {
	case EDSV_EDS_CBK_MSG:
		switch (edsv_msg->info.cbk_info.type) {
		case EDSV_EDS_CHAN_OPEN:
			{
				EDA_CLIENT_HDL_REC *eda_hdl_rec;
				EDA_CHANNEL_HDL_REC *channel_hdl_rec;
				EDSV_EDA_CHAN_OPEN_CBK_PARAM *cbk_param = &edsv_msg->info.cbk_info.param.chan_open_cbk;
	    /** Create the chan hdl record here before 
             ** queing this message onto the priority queue
             ** so that the dispatch by the application to fetch
             ** the callback is instantaneous.
             **/

	    /** Lookup the hdl rec by reg_id 
             **/
				if (NULL == (eda_hdl_rec = eda_find_hdl_rec_by_regid(eda_cb,
										     edsv_msg->info.cbk_info.
										     eds_reg_id))) {
					TRACE_4("client handle record for reg_id: %u not found",
										 edsv_msg->info.cbk_info.eds_reg_id);
					eda_msg_destroy(edsv_msg);
					return NCSCC_RC_FAILURE;
				}

	    /** Create/add a channel record to the hdl rec with 
             ** the information received in this message. 
             ** only if the return status was SA_AIS_OK.
             **/
				if (SA_AIS_OK == cbk_param->error) {
					if (NULL == (channel_hdl_rec = eda_channel_hdl_rec_add(&eda_hdl_rec,
											       cbk_param->chan_id,
											       cbk_param->chan_open_id,
											       cbk_param->
											       chan_open_flags,
											       &cbk_param->
											       chan_name))) {
						TRACE_4("channel add failed for chan_id: %u, chan_open_id: %u, \
							channelname: %s", cbk_param->chan_id, cbk_param->chan_open_id,
											cbk_param->chan_name.value);
						eda_msg_destroy(edsv_msg);
						return NCSCC_RC_FAILURE;
					}

	      /** pass on the channel_hdl to the application thru cbk
               **/
					cbk_param->eda_chan_hdl = channel_hdl_rec->channel_hdl;
				}

	    /** enqueue this message anyway
             **/
				if (NCSCC_RC_SUCCESS != m_NCS_IPC_SEND(&eda_hdl_rec->mbx, edsv_msg, prio)) {
					TRACE_4("IPC send failed failed for msg type: %u", edsv_msg->type);
					return NCSCC_RC_FAILURE;
				}
			}
			break;
		case EDSV_EDS_DELIVER_EVENT:
			{
				EDA_CLIENT_HDL_REC *eda_hdl_rec;
				EDA_CHANNEL_HDL_REC *chan_hdl_rec;
				EDA_EVENT_HDL_REC *evt_hdl_rec;
				EDSV_EDA_EVT_DELIVER_CBK_PARAM *evt_dlv_param =
				    &edsv_msg->info.cbk_info.param.evt_deliver_cbk;

	    /** Lookup the hdl rec 
             **/
				if (NULL == (eda_hdl_rec = eda_find_hdl_rec_by_regid(eda_cb,
										     edsv_msg->info.cbk_info.
										     eds_reg_id))) {
					TRACE_4("reg record not found reg_id: %u", edsv_msg->info.cbk_info.eds_reg_id);
					edsv_free_evt_pattern_array(evt_dlv_param->pattern_array);
					evt_dlv_param->pattern_array = NULL;
		/** free the event data if any **/
					if (evt_dlv_param->data) {
						m_MMGR_FREE_EDSV_EVENT_DATA(evt_dlv_param->data);
						evt_dlv_param->data = NULL;
					}
					eda_msg_destroy(edsv_msg);
					return NCSCC_RC_FAILURE;
				}

	    /** Lookup the channel record to which
             ** this event belongs
             **/
				if (NULL == (chan_hdl_rec = eda_find_chan_hdl_rec_by_chan_id(eda_hdl_rec,
											     evt_dlv_param->chan_id,
											     evt_dlv_param->
											     chan_open_id))) {
					TRACE_4("chan rec not found for chan_id: %u, chan_open_id: %u", 
						evt_dlv_param->chan_id, evt_dlv_param->chan_open_id);
					edsv_free_evt_pattern_array(evt_dlv_param->pattern_array);
					evt_dlv_param->pattern_array = NULL;
		/** free the event data if any **/
					if (evt_dlv_param->data) {
						m_MMGR_FREE_EDSV_EVENT_DATA(evt_dlv_param->data);
						evt_dlv_param->data = NULL;
					}
					eda_msg_destroy(edsv_msg);
					return NCSCC_RC_FAILURE;
				}

	    /** Create/Add the new event record.
             **/
				if (NULL == (evt_hdl_rec = eda_event_hdl_rec_add(&chan_hdl_rec)))
				{
					edsv_free_evt_pattern_array(evt_dlv_param->pattern_array);
					evt_dlv_param->pattern_array = NULL;
		/** free the event data if any **/
					if (evt_dlv_param->data) {
						m_MMGR_FREE_EDSV_EVENT_DATA(evt_dlv_param->data);
						evt_dlv_param->data = NULL;
					}
					eda_msg_destroy(edsv_msg);
					TRACE_4("event record add failed");
					return NCSCC_RC_FAILURE;
				}

	    /** Initialize the fields in the evt_hdl_rec with data
             ** received in the message.
             **/
				evt_hdl_rec->priority = evt_dlv_param->priority;
				evt_hdl_rec->publisher_name = evt_dlv_param->publisher_name;
				evt_hdl_rec->publish_time = evt_dlv_param->publish_time;
				evt_hdl_rec->retention_time = evt_dlv_param->retention_time;
				evt_hdl_rec->event_data_size = evt_dlv_param->data_len;

	    /** mark the event as rcvd.
             **/
				evt_hdl_rec->evt_type |= EDA_EVT_RECEIVED;

	    /** Create/Add the new event inst record.
             **/

	    /** The evt hdl rec will take ownership of the memory
             ** for the patterns & data to avoid too many copies
             ** and not that much use of these in the callback.
             **/
				evt_hdl_rec->del_evt_id = evt_dlv_param->eda_event_id;
				evt_hdl_rec->pattern_array = evt_dlv_param->pattern_array;
				evt_dlv_param->pattern_array = NULL;

				evt_hdl_rec->evt_data = evt_dlv_param->data;
				evt_dlv_param->data = NULL;

				/* assign the newly allocated hdl */
				evt_dlv_param->event_hdl = evt_hdl_rec->event_hdl;

	    /** enqueue this message. MDS & IPC priority match 1-1 
             **/
				if (NCSCC_RC_SUCCESS != m_NCS_IPC_SEND(&eda_hdl_rec->mbx, edsv_msg, prio)) {
					TRACE_4("IPC send failed for msg type: %u", edsv_msg->type);
					return NCSCC_RC_FAILURE;
				}

			}
			break;
		case EDSV_EDS_CLMNODE_STATUS:
			{
				EDSV_EDA_CLM_STATUS_CBK_PARAM *clm_status_param =
				    &edsv_msg->info.cbk_info.param.clm_status_cbk;

				eda_cb->node_status = (SaClmClusterChangesT)clm_status_param->node_status;
				TRACE_1("Local node membership changed to : %u", eda_cb->node_status);
			}
			break;
		default:
			 TRACE_3("unknown message type: %u", edsv_msg->info.cbk_info.type);
			return NCSCC_RC_FAILURE;
			break;
		}
		break;
	case EDSV_EDS_MISC_MSG:
      /** No messages conceived yet **/
		TRACE_1("Unsupported message type");
		return NCSCC_RC_FAILURE;
		break;
	default:
      /** Unexpected message **/
		TRACE_4("Wrong message type");
		return NCSCC_RC_FAILURE;
		break;
	}