if(trigger_transition) { register_fsa_action(A_TE_CANCEL);
if(update_cache) { crm_debug("Updating cache after event %s", ccm_event_name(event));  crm_malloc0(event_data, sizeof(struct crmd_ccm_data_s)); if(event_data != NULL) { return; }  event_data->event = event; if(data != NULL) { event_data->oc = copy_ccm_oc_data(data); } register_fsa_input_later( C_CCM_CALLBACK, I_CCM_EVENT, event_data);  if (event_data->oc) { crm_free(event_data->oc); event_data->oc = NULL; } crm_free(event_data);
crmd_ccm_msg_callback(	oc_ed_t event, void *cookie, size_t size, const void *data){	int instance = -1;	gboolean update_cache = FALSE;	struct crmd_ccm_data_s *event_data = NULL;	const oc_ev_membership_t *membership = data;	gboolean update_quorum = FALSE;	gboolean trigger_transition = FALSE;	crm_devel("received callback");	if(data != NULL) {		instance = membership->m_instance;	}		crm_info("Quorum %s after event=%s (id=%d)", 		 ccm_have_quorum(event)?"(re)attained":"lost",		 ccm_event_name(event), instance);		switch(event) {		case OC_EV_MS_NEW_MEMBERSHIP:		case OC_EV_MS_INVALID:			update_cache = TRUE;			update_quorum = TRUE;			if(AM_I_DC) {				trigger_transition = TRUE;			}			break;		case OC_EV_MS_NOT_PRIMARY:#if UNTESTED			if(AM_I_DC == FALSE) {				break;			}			/* tell the TE to pretend it completed and stop */			/* side effect: we'll end up in S_IDLE */			register_fsa_action(A_TE_HALT);#endif			break;		case OC_EV_MS_PRIMARY_RESTORED:			if(AM_I_DC) {				fsa_membership_copy->id = instance;				trigger_transition = TRUE;			}			break;		case OC_EV_MS_EVICTED:			update_quorum = TRUE;			register_fsa_input(C_FSA_INTERNAL, I_STOP, NULL);			break;		default:			crm_err("Unknown CCM event: %d", event);	}	if(update_quorum && ccm_have_quorum(event) == FALSE) {		/* did we just loose quorum? */		if(fsa_have_quorum		   && (fsa_state == S_POLICY_ENGINE		       || fsa_state == S_TRANSITION_ENGINE		       || fsa_state == S_IDLE)) {			crm_info("Quorum lost: triggering transition (%s)",				 ccm_event_name(event));			trigger_transition = TRUE;		}		fsa_have_quorum = FALSE;				} else if(update_quorum)  {		fsa_have_quorum = TRUE;	}	if(trigger_transition) {		register_fsa_action(A_TE_CANCEL);	}	if(update_cache) {		crm_malloc0(event_data, sizeof(struct crmd_ccm_data_s));		if(event_data != NULL) {			event_data->event = event;			if(data != NULL) {				event_data->oc = copy_ccm_oc_data(					(const oc_ev_membership_t *)data);			}			crm_devel("Sending callback to the FSA");			register_fsa_input_later(				C_CCM_CALLBACK, I_CCM_EVENT, event_data);						if (event_data->oc) {				crm_free(event_data->oc);				event_data->oc = NULL;			}			crm_free(event_data);		}	} else {		crm_debug("No futher action for transitional CCM event: %s",			  ccm_event_name(event));	}		oc_ev_callback_done(cookie);	return;}