crm_debug("Input message"); crm_log_message(LOG_DEBUG, op_request); 
cib_common_callback(	IPC_Channel *channel, gpointer user_data, gboolean privileged){	int rc = cib_ok;	int lpc = 0;	int call_type = 0;	int call_options = 0;	const char *op = NULL;	const char *host = NULL;		HA_Message *op_request = NULL;	HA_Message *op_reply   = NULL;	gboolean needs_processing = FALSE;	cib_client_t *cib_client = user_data;	if(cib_client == NULL) {		crm_err("Receieved call from unknown source. Discarding.");		return FALSE;	}		crm_debug_2("Callback for %s on %s channel",		    cib_client->id, cib_client->channel_name);	while(channel->ops->is_message_pending(channel)) {		if (channel->ch_status != IPC_CONNECT) {			/* The message which was pending for us is that			 * the channel is no longer fully connected.			 *			 * Dont read requests from disconnected clients			 */			break;		}		op_request = msgfromIPC(channel, 0);		if (op_request == NULL) {			perror("Receive failure:");			break;		}		crm_debug_2("Processing IPC message from %s on %s channel",			    cib_client->id, cib_client->channel_name); 		crm_log_message(LOG_MSG, op_request);		crm_log_message_adv(LOG_DEBUG_3, "Client[inbound]", op_request);				lpc++;		rc = cib_ok;				if(HA_OK != ha_msg_add(			   op_request, F_CIB_CLIENTID, cib_client->id)) {			crm_err("Couldnt add F_CIB_CLIENTID to message");			rc = cib_msg_field_add;		}		if(rc == cib_ok) {			ha_msg_value_int(				op_request, F_CIB_CALLOPTS, &call_options);			crm_debug_3("Call options: %.8lx", (long)call_options);						host = cl_get_string(op_request, F_CIB_HOST);			op = cl_get_string(op_request, F_CIB_OPERATION);			rc = cib_get_operation_id(op_request, &call_type);		}				if(rc == cib_ok		   && cib_server_ops[call_type].needs_privileges		   && privileged == FALSE) {			rc = cib_not_authorized;		}		needs_processing = FALSE;		if(rc != cib_ok) {			/* TODO: construct error reply */			crm_err("Pre-processing of command failed: %s",				cib_error2string(rc));					} else if(host == NULL && cib_is_master			&& !(call_options & cib_scope_local)) { 			crm_debug("Processing master %s op locally", op);			needs_processing = TRUE;		} else if(			(host == NULL && (call_options & cib_scope_local))			  || safe_str_eq(host, cib_our_uname)) { 			crm_debug("Processing %s op locally", op);			needs_processing = TRUE;		} else {			/* send via HA to other nodes */			ha_msg_add(op_request, F_CIB_DELEGATED, cib_our_uname);			crm_log_message(LOG_MSG, op_request);			if(host != NULL) {				crm_debug_2("Forwarding %s op to %s", op, host);				send_ha_message(hb_conn, op_request, host);			} else {				crm_debug_2("Forwarding %s op to master instance",					 op);				send_ha_message(hb_conn, op_request, NULL);			}			if(call_options & cib_discard_reply) {				crm_debug_2("Client not interested in reply");			} else if(call_options & cib_sync_call) {				/* keep track of the request so we can time it				 * out if required				 */				HA_Message *saved = cib_msg_copy(					op_request, TRUE);				crm_debug_3("Registering delegated call from %s",					  cib_client->id);				cib_client->delegated_calls = g_list_append(					cib_client->delegated_calls, saved);			}			crm_msg_del(op_request);			op_request = NULL;			continue;		}		if(needs_processing) { 			crm_debug("Processing %s op", op);			rc = cib_process_command(				op_request, &op_reply, privileged);			crm_debug("Performing local processing: op=%s origin=%s/%s,%s (update=%s)",				  op, cib_our_uname, cib_client->id,				  cl_get_string(op_request, F_CIB_CALLID),				  (rc==cib_ok && cib_server_ops[call_type].modifies_cib)?"true":"false");			if(rc == cib_ok && safe_str_eq(op, CRM_OP_CIB_SYNC)) {				HA_Message *sync_data = cl_get_struct(					op_reply, F_CIB_CALLDATA);				CRM_DEV_ASSERT(sync_data != NULL);				ha_msg_mod(op_request,					   F_CIB_OPERATION, CRM_OP_CIB_REPLACE);				ha_msg_add(op_request,					   F_CIB_GLOBAL_UPDATE, XML_BOOLEAN_TRUE);				cl_msg_modstruct(					op_request, F_CIB_CALLDATA, sync_data); 			}			crm_debug_3("Processing complete");		}				crm_debug_3("processing response cases");		if(rc != cib_ok) {			crm_debug("Input message");			crm_log_message(LOG_DEBUG, op_request);			crm_err("%s operation failed: %s",				crm_str(op), cib_error2string(rc));			crm_log_message_adv(LOG_DEBUG, "CIB[output]", op_reply);		}				if(op_reply == NULL) {			crm_debug_4("No reply is required for op %s",crm_str(op));					} else if(call_options & cib_sync_call) { 			crm_debug_3("Sending sync reply to %s op", crm_str(op));			crm_log_message(LOG_MSG, op_reply);			if(send_ipc_message(channel, op_reply) == FALSE) {				crm_err("Sync reply failed: %s",					 cib_error2string(cib_reply_failed));			}					} else {			enum cib_errors local_rc = cib_ok;			/* send reply via client's callback channel */ 			crm_debug_3("Sending async reply %p to %s op",				  op_reply, crm_str(op));			crm_log_message(LOG_MSG, op_reply);			local_rc = send_via_callback_channel(				op_reply, cib_client->callback_id);			if(local_rc != cib_ok) {				crm_warn("ASync reply failed: %s",					 cib_error2string(local_rc));			}		}		op_reply = NULL;		crm_debug_3("Processing forward cases");		if(rc == cib_ok && safe_str_eq(op, CRM_OP_CIB_SYNC)) {			const char *section = cl_get_string(				op_request, F_CIB_SECTION); 			crm_info("Syncing section=%s to all instances",				 section?section:"<all>");			send_ha_message(hb_conn, op_request, NULL);		} else if(rc == cib_ok		   && cib_server_ops[call_type].modifies_cib		   && !(call_options & cib_inhibit_bcast)) {			/* send via HA to other nodes */ 			crm_debug("Forwarding %s op to all instances", op);			ha_msg_add(op_request,				   F_CIB_GLOBAL_UPDATE, XML_BOOLEAN_TRUE);			send_ha_message(hb_conn, op_request, NULL);					} else {			if(call_options & cib_inhibit_bcast ) {				crm_debug_3("Request not broadcast: inhibited");			}			if(cib_server_ops[call_type].modifies_cib == FALSE) {				crm_debug_3("Request not broadcast: R/O call");			}			if(rc != cib_ok) {				crm_debug("Request not broadcast:"					  " call failed: %s",					  cib_error2string(rc));			}		}		crm_debug_3("Cleaning up request");		crm_msg_del(op_request);		op_request = NULL;	}	crm_debug_2("Processed %d messages", lpc);    	return cib_process_disconnect(channel, cib_client);}
8182	/local/tlutelli/issta_data/temp/c/2005_temp/2005/8182/74c802adf6a84f2e7b5c0f887576242d576aecd9/callbacks.c/buggy/crm/cib/callbacks.c