Exemplo n.º 1
0
/****************************************************************************
  Name          : eda_event_hdl_rec_del
 
  Description   : This routine deletes the a event handle record from
                  a list of event hdl records. 
 
  Arguments     : EDA_EVENT_HDL_REC **list_head
                  EDA_EVENT_HDL_REC *rm_node

 
  Return Values : None
 
  Notes         : 
******************************************************************************/
uns32 eda_event_hdl_rec_del(EDA_EVENT_HDL_REC **list_head, EDA_EVENT_HDL_REC *rm_node)
{
	/* Find the event hdl record in the list of records */
	EDA_EVENT_HDL_REC *list_iter = *list_head;

	/* If the to be removed record is the first record */
	if (list_iter == rm_node) {
		*list_head = rm_node->next;
      /** remove the association with hdl-mngr 
       **/
		ncshm_give_hdl(rm_node->event_hdl);
		ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, rm_node->event_hdl);
      /** free pattern_array if any **/
		edsv_free_evt_pattern_array(rm_node->pattern_array);
      /** free the event data if any **/
		if (rm_node->evt_data) {
			m_MMGR_FREE_EDSV_EVENT_DATA(rm_node->evt_data);
			rm_node->evt_data = NULL;
		}
      /** Free the event hdl record 
       **/
		m_MMGR_FREE_EDA_EVENT_HDL_REC(rm_node);
		return NCSCC_RC_SUCCESS;
	} else {		/* find the rec */

		while (NULL != list_iter) {
			if (list_iter->next == rm_node) {
				list_iter->next = rm_node->next;
	    /** remove the association with hdl-mngr 
             **/
				ncshm_give_hdl(rm_node->event_hdl);
				ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, rm_node->event_hdl);
	    /** free pattern_array if any **/
				edsv_free_evt_pattern_array(rm_node->pattern_array);
	    /** free the event data if any **/
				if (rm_node->evt_data) {
					m_MMGR_FREE_EDSV_EVENT_DATA(rm_node->evt_data);
					rm_node->evt_data = NULL;
				}
	    /** Free the event hdl record 
             **/
				m_MMGR_FREE_EDA_EVENT_HDL_REC(rm_node);
				return NCSCC_RC_SUCCESS;
			}

			/* move onto the next one */
			list_iter = list_iter->next;
		}
	}
   /** The node couldn't be deleted **/
	m_LOG_EDSV_A(EDA_FAILURE, NCSFL_LC_EDSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__, 0);
	return NCSCC_RC_FAILURE;
}
Exemplo n.º 2
0
/****************************************************************************
 * Name          : eds_evt_destroy
 *
 * Description   : This is the function which is called to destroy an EDS event.
 *
 * Arguments     : struct edsv_eds_evt_tag *.
 *
 * Return Values : NONE
 *
 * Notes         : None.
 *****************************************************************************/
void eds_evt_destroy(EDSV_EDS_EVT *evt)
{
	TRACE_ENTER();

	if (EDSV_EDS_EDSV_MSG == evt->evt_type) {
		if (EDSV_EDA_API_MSG == evt->info.msg.type) {
			if (EDSV_EDA_PUBLISH == evt->info.msg.info.api_info.type) {
				/* free the pattern array */
				if (NULL != evt->info.msg.info.api_info.param.publish.pattern_array)
					edsv_free_evt_pattern_array(evt->info.msg.info.api_info.param.publish.
								    pattern_array);

				/* free event data */
				if (NULL != evt->info.msg.info.api_info.param.publish.data)
					m_MMGR_FREE_EDSV_EVENT_DATA(evt->info.msg.info.api_info.param.publish.data);

			} else if (EDSV_EDA_SUBSCRIBE == evt->info.msg.info.api_info.type) {
				/* free the filter array */
				if (NULL != evt->info.msg.info.api_info.param.subscribe.filter_array)
					edsv_free_evt_filter_array(evt->info.msg.info.api_info.param.subscribe.
								   filter_array);
			}
		}
	}

   /** There are no other pointers 
    ** off the evt, so free the evt
    **/
	m_MMGR_FREE_EDSV_EDS_EVT(evt);
	evt = NULL;

	TRACE_LEAVE();
	return;
}
Exemplo n.º 3
0
/****************************************************************************
  Name          : eda_event_hdl_rec_list_del
 
  Description   : This routine deletes a list of event records.
 
  Arguments     : pointer to the list of event records anchor.
 
  Return Values : None
 
  Notes         : 
******************************************************************************/
static void eda_event_hdl_rec_list_del(EDA_EVENT_HDL_REC **pevent_hdl)
{
	EDA_EVENT_HDL_REC *event_hdl;
	while (NULL != (event_hdl = *pevent_hdl)) {
		*pevent_hdl = event_hdl->next;

		ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, event_hdl->event_hdl);
      /** free pattern_array if any **/
		edsv_free_evt_pattern_array(event_hdl->pattern_array);
      /** free the event data if any **/
		if (event_hdl->evt_data) {
			m_MMGR_FREE_EDSV_EVENT_DATA(event_hdl->evt_data);
			event_hdl->evt_data = NULL;
		}
      /** remove the association with hdl-mngr 
       **/
		m_MMGR_FREE_EDA_EVENT_HDL_REC(event_hdl);
		event_hdl = NULL;
	}

}
Exemplo n.º 4
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;
	}