startTimer(dc_heartbeat);
if(dc_heartbeat->source_id == (guint)-1 || dc_heartbeat->source_id == (guint)-2) { crm_debug("Starting DC Heartbeat timer"); dc_heartbeat->source_id = Gmain_timeout_add_full( G_PRIORITY_HIGH, dc_heartbeat->period_ms, dc_heartbeat->callback, dc_heartbeat, NULL); } else { crm_debug("DC Heartbeat timer already active"); }
do_dc_takeover(long long action,	       enum crmd_fsa_cause cause,	       enum crmd_fsa_state cur_state,	       enum crmd_fsa_input current_input,	       fsa_data_t *msg_data){	enum crmd_fsa_input result = I_NULL;	crm_data_t *cib = createEmptyCib();	crm_data_t *update = NULL;	crm_data_t *output = NULL;	int rc = cib_ok;		crm_trace("################## Taking over the DC ##################");	set_bit_inplace(fsa_input_register, R_THE_DC);	crm_verbose("Am I the DC? %s", AM_I_DC?XML_BOOLEAN_YES:XML_BOOLEAN_NO);	crm_free(fsa_our_dc);	fsa_our_dc = crm_strdup(fsa_our_uname);	set_bit_inplace(fsa_input_register, R_JOIN_OK);	set_bit_inplace(fsa_input_register, R_INVOKE_PE);		clear_bit_inplace(fsa_input_register, R_CIB_DONE);	clear_bit_inplace(fsa_input_register, R_HAVE_CIB);	startTimer(dc_heartbeat);	fsa_cib_conn->cmds->set_slave_all(fsa_cib_conn, cib_none);	fsa_cib_conn->cmds->set_master(fsa_cib_conn, cib_none);	crm_debug("Update %s in the CIB to our uuid: %s",		  XML_ATTR_DC_UUID, crm_element_value(cib, XML_ATTR_DC_UUID));		set_uuid(fsa_cluster_conn, cib, XML_ATTR_DC_UUID, fsa_our_uname);	update = create_cib_fragment(cib, NULL);	free_xml(cib);	rc = fsa_cib_conn->cmds->modify(		fsa_cib_conn, NULL, update, &output,		cib_sync_call|cib_verbose);		if(rc == cib_ok) {		int revision_i = -1;		const char *revision = NULL;		crm_debug("Checking our feature revision is allowed: %d",			  cib_feature_revision);		cib = find_xml_node(output, XML_TAG_CIB, TRUE);				revision = crm_element_value(cib, XML_ATTR_CIB_REVISION);		revision_i = atoi(revision?revision:"0");		if(revision_i > cib_feature_revision) {			crm_err("Feature revision not permitted");			/* go into a stall state */			result = I_HALT;		}	} else if(rc == cib_revision_unsupported) {		crm_err("Feature revision not permitted");		/* go into a stall state */		result = I_HALT;			} else 	if(rc != cib_ok) {		crm_err("DC UUID update failed: %s", cib_error2string(rc));		result = I_FAIL;	}		free_xml(update);		crm_debug("Requesting an initial dump of CRMD client_status");	fsa_cluster_conn->llc_ops->client_status(		fsa_cluster_conn, NULL, CRM_SYSTEM_CRMD, -1);		return result;}