CRM_DEBUG("About to interrogate xml"); xmlNodePtr root_xml_node = xmlDocGetRootElement(doc); CRM_DEBUG("Got the root element");  xmlNodePtr msg_xml_node = validate_crm_message(root_xml_node, CRM_SYSTEM_CIB, NULL, XML_MSG_TAG_REQUEST);  if (msg_xml_node != NULL) { CRM_DEBUG("The message is good, processing"); xmlNodePtr answer = processCibRequest(msg_xml_node); CRM_DEBUG("Directing reply"); if (send_ipc_reply(client, root_xml_node, answer) == FALSE) cl_log(LOG_WARNING, "Cib answer could not be sent"); free_xml(answer); } else if (root_xml_node != NULL) cl_log(LOG_INFO, "Received a message for (%s) by mistake", xmlGetProp(root_xml_node, XML_MSG_ATTR_SYSTO)); else cl_log(LOG_INFO, "Root node was NULL!!");  free_xml(root_xml_node); msg->msg_done(msg); }  CRM_DEBUG2("Processed %d messages", lpc); if (client->ch_status == IPC_DISCONNECT) { cl_log(LOG_INFO, "cib_input_dispatch: received HUP (2)");
CRM_DEBUG2("Processed %d messages", lpc); if (client->ch_status == IPC_DISCONNECT) { cl_log(LOG_INFO, "the client has left us: received HUP");
cib_input_dispatch(IPC_Channel *client, gpointer user_data){    int lpc = 0;    gboolean hack_return_good = TRUE;        IPC_Message *msg = NULL;    while(client->ch_status != IPC_DISCONNECT && client->ops->is_message_pending(client) == TRUE)    {		if (client->ops->recv(client, &msg) != IPC_OK)		{			perror("Receive failure:");			FNRET(!hack_return_good);		}			if (msg == NULL)		{			CRM_DEBUG("No message this time");			continue;		}		lpc++;		CRM_DEBUG2("Got message [body=%s]", (char*)msg->msg_body);			char *buffer = (char*)msg->msg_body;		cl_log(LOG_DEBUG, "Got xml [text=%s]", buffer);		xmlInitParser(); // docs say only do this once, but in their code they do it every time!		xmlDocPtr doc = xmlParseMemory(buffer, strlen(buffer));		CRM_DEBUG("Finished parsing buffer as XML");		if (doc == NULL)		{			cl_log(LOG_INFO, "XML Buffer was not valid...\n Buffer: (%s)", buffer);			continue;		}			CRM_DEBUG("About to interrogate xml");		xmlNodePtr root_xml_node = xmlDocGetRootElement(doc);		CRM_DEBUG("Got the root element");			xmlNodePtr msg_xml_node = validate_crm_message(root_xml_node,													   CRM_SYSTEM_CIB,													   NULL,													   XML_MSG_TAG_REQUEST);			if (msg_xml_node != NULL)		{			CRM_DEBUG("The message is good, processing");			xmlNodePtr answer = processCibRequest(msg_xml_node);			CRM_DEBUG("Directing reply");			if (send_ipc_reply(client, root_xml_node, answer) == FALSE)				cl_log(LOG_WARNING, "Cib answer could not be sent");			free_xml(answer);//xmlFreeNode(answer);		}		else if (root_xml_node != NULL)			cl_log(LOG_INFO, "Received a message for (%s) by mistake",				   xmlGetProp(root_xml_node, XML_MSG_ATTR_SYSTO));		else			cl_log(LOG_INFO, "Root node was NULL!!");		free_xml(root_xml_node);		msg->msg_done(msg);    }    CRM_DEBUG2("Processed %d messages", lpc);    if (client->ch_status == IPC_DISCONNECT)    {		cl_log(LOG_INFO, "cib_input_dispatch: received HUP (2)");		FNRET(!hack_return_good);    }    FNRET(hack_return_good);}