crm_debug("Be informed of CRM Client Status changes"); if (HA_OK != hb_conn->llc_ops->set_cstatus_callback( hb_conn, cib_client_status_callback, hb_conn)) {  crm_err("Cannot set cstatus callback: %s\n", hb_conn->llc_ops->errmsg(hb_conn)); was_error = TRUE; } else { crm_info("Client Status callback set"); } }  if(was_error == FALSE) { gboolean did_fail = TRUE; int num_ccm_fails = 0; int max_ccm_fails = 30; int ret; int cib_ev_fd;  while(did_fail && was_error == FALSE) { did_fail = FALSE; crm_info("Registering with CCM"); ret = oc_ev_register(&cib_ev_token); if (ret != 0) { crm_warn("CCM registration failed"); did_fail = TRUE; }  if(did_fail == FALSE) { crm_info("Setting up CCM callbacks"); ret = oc_ev_set_callback( cib_ev_token, OC_EV_MEMB_CLASS, cib_ccm_msg_callback, NULL); if (ret != 0) { crm_warn("CCM callback not set"); did_fail = TRUE; } } if(did_fail == FALSE) { oc_ev_special(cib_ev_token, OC_EV_MEMB_CLASS, 0);  crm_info("Activating CCM token"); ret = oc_ev_activate(cib_ev_token, &cib_ev_fd); if (ret != 0){ crm_warn("CCM Activation failed"); did_fail = TRUE; } }  if(did_fail) { num_ccm_fails++; oc_ev_unregister(cib_ev_token);  if(num_ccm_fails < max_ccm_fails){ crm_warn("CCM Connection failed" " %d times (%d max)", num_ccm_fails, max_ccm_fails); sleep(1);  } else { crm_err("CCM Activation failed %d (max) times", num_ccm_fails); was_error = TRUE;  } } }  crm_info("CCM Activation passed... all set to go!"); G_main_add_fd(G_PRIORITY_LOW, cib_ev_fd, FALSE, cib_ccm_dispatch, cib_ev_token, default_ipc_connection_destroy); }  if(was_error == FALSE) {  crm_debug("Requesting an initial dump of CRMD client_status"); hb_conn->llc_ops->client_status( hb_conn, NULL, CRM_SYSTEM_CRMD, -1);
init_start(void){	gboolean was_error = FALSE;	hb_conn = ll_cluster_new("heartbeat");	cib_register_ha(hb_conn, CRM_SYSTEM_CIB);	if(startCib(CIB_FILENAME) == FALSE){		crm_crit("Cannot start CIB... terminating");		exit(1);	}		was_error = init_server_ipc_comms(		crm_strdup("cib_callback"), cib_client_connect,		default_ipc_connection_destroy);	was_error = was_error || init_server_ipc_comms(		crm_strdup("cib_ro"), cib_client_connect,		default_ipc_connection_destroy);	was_error = was_error || init_server_ipc_comms(		crm_strdup("cib_rw"), cib_client_connect,		default_ipc_connection_destroy);	if(was_error == FALSE) {		/* Create the mainloop and run it... */		mainloop = g_main_new(FALSE);		crm_info("Starting %s mainloop", crm_system_name);				Gmain_timeout_add(1000, cib_msg_timeout, NULL);				g_main_run(mainloop);		return_to_orig_privs();	} else {		crm_err("Couldnt start all communication channels, exiting.");	}		return 0;}