const char *crm_msg_reference  = xmlGetProp(xml_relay_message, XML_MSG_ATTR_REFERENCE); const char *sys_from   = xmlGetProp(xml_relay_message, XML_MSG_ATTR_SYSFROM); const char *host_to    = xmlGetProp(xml_relay_message, XML_MSG_ATTR_HOSTTO); const char *sys_to     = xmlGetProp(xml_relay_message, XML_MSG_ATTR_SYSTO); const char *type       = xmlGetProp(xml_relay_message, XML_MSG_ATTR_MSGTYPE); char *dest_node = NULL;
const char *host_to = xmlGetProp(xml_relay_message, XML_ATTR_HOSTTO); const char *sys_to  = xmlGetProp(xml_relay_message, XML_ATTR_SYSTO); gboolean processing_complete = FALSE; int is_for_dc  = 0; int is_for_dcib  = 0; int is_for_crm = 0; int is_local   = 0;
relay_message(xmlNodePtr xml_relay_message,	      gboolean originated_locally,	      const char *host_from){	const char *crm_msg_reference  = xmlGetProp(xml_relay_message,						    XML_MSG_ATTR_REFERENCE);	const char *sys_from   = xmlGetProp(xml_relay_message,					    XML_MSG_ATTR_SYSFROM);	const char *host_to    = xmlGetProp(xml_relay_message,					    XML_MSG_ATTR_HOSTTO);	const char *sys_to     = xmlGetProp(xml_relay_message,					    XML_MSG_ATTR_SYSTO);	const char *type       = xmlGetProp(xml_relay_message,					    XML_MSG_ATTR_MSGTYPE);	char *dest_node = NULL;	int is_for_dc  = 0;	int is_for_crm = 0;	int is_request = 0;	int is_local   = 0;	gboolean processing_complete = FALSE;		FNIN();	if (sys_to == NULL || crm_msg_reference == NULL || type == NULL) {		cl_log(LOG_DEBUG,		       "relay_message: Invalid message, (%s, %s, %s) discarding.",		       sys_to, crm_msg_reference, type);		FNRET(TRUE); // Discard.  Should have been picked up by now anyway	}    	is_for_dc  = (strcmp(CRM_SYSTEM_DC, sys_to) == 0);	is_for_crm = (strcmp(CRM_SYSTEM_CRMD, sys_to) == 0);	is_request = (strcmp("request", type) == 0);	is_local   = (host_to == NULL		      || strlen(host_to) == 0		      || strcmp(our_uname, host_to) == 0);	CRM_DEBUG("relaying message");	CRM_DEBUG2("originated locally %d", originated_locally);	CRM_DEBUG2("is dc %d", is_for_dc);	CRM_DEBUG2("is crm %d", is_for_crm);	CRM_DEBUG2("is request %d", is_request);	CRM_DEBUG2("is local %d", is_local);	CRM_DEBUG2("our host [%s]", our_uname);	CRM_DEBUG2("dest host [%s]", host_to);    	if (is_request == 1 && is_for_dc == 0 && originated_locally == FALSE) {		/* save host/crm_msg_reference in routing table		 * so that responses will be directed appropriately		 */		CRM_DEBUG("Generating key to look up hash table with");		gpointer action_ref =			(gpointer)generate_hash_key(crm_msg_reference, sys_to);		CRM_DEBUG2("key (%s)", (char*)action_ref);		if(g_hash_table_lookup(pending_remote_replies, action_ref) == NULL){			CRM_DEBUG2(				"Updating crm_msg_reference table for %s",				host_from);			gpointer value =				(gpointer)generate_hash_value(host_from,							      sys_from);			CRM_DEBUG2("value (%s)", (char*)value);			g_hash_table_insert (pending_remote_replies,					     action_ref,					     value);			/* remove from the table based on FIFO or a timed sweep			 *    or something			 *			 * cleanup_crm_msg_referenceTable();			 */		} else {			cl_log(LOG_INFO,			       "Already processing a message with crm_msg_reference "			       "number (%s) for sub-system (%s)... discarding message.",			       crm_msg_reference, sys_to);			processing_complete = TRUE;		}	}	if (is_for_dc) {		// only forward dc messages if they originated locally		if (originated_locally && i_am_dc == FALSE) {			// DC Messages are always broadcast			send_msg_via_ha(xml_relay_message, NULL);			processing_complete = TRUE;		} else if (i_am_dc == FALSE) {			processing_complete = TRUE;  // ignore		}	} else if (is_local) {		if (!is_for_crm) {			send_msg_via_ipc(xml_relay_message, sys_to);			processing_complete = TRUE;		}	} else {		dest_node = find_destination_host(xml_relay_message,						  crm_msg_reference,						  sys_from,						  is_request);		send_msg_via_ha(xml_relay_message, dest_node);		processing_complete = TRUE;	}	FNRET(processing_complete);}