CRM_DEV_ASSERT(native->callback_channel->send_queue->current_qlen < native->callback_channel->send_queue->max_qlen);
cib_native_signon(cib_t* cib, const char *name, enum cib_conn_type type){	int rc = cib_ok;	char *uuid_ticket = NULL;	struct ha_msg *reg_msg = NULL;	cib_native_opaque_t *native = cib->variant_opaque;	crm_trace("Connecting command channel");	if(type == cib_command) {		cib->state = cib_connected_command;		native->command_channel = init_client_ipc_comms_nodispatch(			cib_channel_rw);	} else {		cib->state = cib_connected_query;		native->command_channel = init_client_ipc_comms_nodispatch(			cib_channel_ro);	}	if(native->command_channel == NULL) {		crm_debug("Connection to command channel failed");		rc = cib_connection;			} else if(native->command_channel->ch_status != IPC_CONNECT) {		crm_err("Connection may have succeeded,"			" but authentication to command channel failed");		rc = cib_authentication;	}		if(rc == cib_ok) {		crm_trace("Connecting callback channel");		native->callback_source = init_client_ipc_comms(			cib_channel_callback, cib_native_dispatch, cib, &(native->callback_channel));				if(native->callback_channel == NULL) {			crm_debug("Connection to callback channel failed");			rc = cib_connection;		} else if(native->callback_source == NULL) {			crm_err("Callback source not recorded");			rc = cib_connection;		} else {			native->callback_channel->send_queue->max_qlen = 500;		}		} else if(rc == cib_ok		  && native->callback_channel->ch_status != IPC_CONNECT) {		crm_err("Connection may have succeeded,"			" but authentication to callback channel failed");		rc = cib_authentication;	}	if(rc == cib_ok) {		const char *msg_type = NULL;		crm_trace("Waiting for msg on command channel");		reg_msg = msgfromIPC_noauth(native->command_channel);		msg_type = cl_get_string(reg_msg, F_CIB_OPERATION);		if(safe_str_neq(msg_type, CRM_OP_REGISTER) ) {			crm_err("Invalid registration message: %s", msg_type);			rc = cib_registration_msg;		} else {			const char *tmp_ticket = NULL;			crm_trace("Retrieving callback channel ticket");			tmp_ticket = cl_get_string(				reg_msg, F_CIB_CALLBACK_TOKEN);			if(tmp_ticket == NULL) {				rc = cib_callback_token;			} else {				uuid_ticket = crm_strdup(tmp_ticket);			}		}		crm_msg_del(reg_msg);		reg_msg = NULL;			}	if(rc == cib_ok) {		crm_trace("Registering callback channel with ticket %s",			  crm_str(uuid_ticket));		reg_msg = ha_msg_new(2);		ha_msg_add(reg_msg, F_CIB_OPERATION, CRM_OP_REGISTER);		ha_msg_add(reg_msg, F_CIB_CALLBACK_TOKEN, uuid_ticket);		ha_msg_add(reg_msg, F_CIB_CLIENTNAME, name);/* 		CRM_DEV_ASSERT(native->command_channel->should_send_blocking); */		if(msg2ipcchan(reg_msg, native->callback_channel) != HA_OK) {			rc = cib_callback_register;		}		CRM_DEV_ASSERT(native->callback_channel->send_queue->current_qlen < native->callback_channel->send_queue->max_qlen);		crm_free(uuid_ticket);		crm_msg_del(reg_msg);	}	if(rc == cib_ok) {		crm_trace("wait for the callback channel setup to complete");		reg_msg = msgfromIPC_noauth(native->callback_channel);		if(reg_msg == NULL) {			crm_err("Connection to callback channel not maintined");			rc = cib_connection;		}		crm_msg_del(reg_msg);	}		if(rc == cib_ok) {		crm_info("Connection to CIB successful");		return cib_ok;	}	crm_warn("Connection to CIB failed: %s", cib_error2string(rc));	cib_native_signoff(cib);	return rc;}