⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 messages.c

📁 linux集群服务器软件代码包
💻 C
📖 第 1 页 / 共 2 页
字号:
		result = cib_ACTIVATION;	}	if (verbose || result != cib_ok) {		if(answer != NULL) {			*answer = createCibFragmentAnswer(section_name, NULL);		}	}		cib_post_notify(op, the_update, result,			get_object_root(section_name, get_the_CIB()));	crm_free(section_name);	return result;}/* FILE *msg_cibup_strm = NULL; */enum cib_errors cib_process_modify(	const char *op, int options, const char *section, crm_data_t *input,	crm_data_t **answer){	gboolean verbose = FALSE;	enum cib_errors result = cib_ok;	char *section_name = NULL;	crm_data_t *failed = NULL;	crm_data_t *cib_update = NULL;	crm_data_t *the_update = NULL;		int cib_update_op = CIB_OP_NONE;	crm_data_t *tmpCib  = NULL;	crm_debug("Processing \"%s\" event for section=%s", op, crm_str(section));	failed  = create_xml_node(NULL, XML_TAG_FAILED);	if (strcmp(CRM_OP_CIB_CREATE, op) == 0) {		cib_update_op = CIB_OP_ADD;			} else if (strcmp(CRM_OP_CIB_UPDATE, op) == 0		   || strcmp(CRM_OP_JOINACK, op) == 0		   || strcmp(CRM_OP_SHUTDOWN_REQ, op) == 0) {		cib_update_op = CIB_OP_MODIFY;			} else if (strcmp(CRM_OP_CIB_DELETE, op) == 0) {		cib_update_op = CIB_OP_DELETE;			} else {		crm_err("Incorrect request handler invoked for \"%s\" op",			crm_str(op));		return cib_operation;	}	result = cib_ok;	if (options & cib_verbose) {		verbose = TRUE;	}		if(safe_str_eq(XML_CIB_TAG_SECTION_ALL, section)) {		section = NULL;	}	if(input == NULL) {		crm_err("Cannot perform modification with no data");		return cib_NOOBJECT;	}		tmpCib = copy_xml_node_recursive(get_the_CIB());	cib_update = find_xml_node(input, XML_TAG_CIB, TRUE);		/* do logging */	the_update = get_object_root(section, cib_update);	crm_validate_data(the_update);	crm_validate_data(tmpCib);	cib_pre_notify(op, get_object_root(section, tmpCib), the_update);	crm_validate_data(the_update);	crm_validate_data(tmpCib);		result = revision_check(cib_update, tmpCib, options);			copy_in_properties(tmpCib, cib_update);		/* make changes to a temp copy then activate */	if(section == NULL) {		/* order is no longer important here */		section_name = crm_strdup(crm_element_name(tmpCib));			if(result == cib_ok) {			result = updateList(				tmpCib, input, failed, cib_update_op,				XML_CIB_TAG_NODES);		}				if(result == cib_ok) {			result = updateList(				tmpCib, input, failed,				cib_update_op, XML_CIB_TAG_RESOURCES);		}		if(result == cib_ok) {			result = updateList(				tmpCib, input, failed,				cib_update_op, XML_CIB_TAG_CONSTRAINTS);		}		if(result == cib_ok) {			result = updateList(tmpCib, input, failed,					    cib_update_op, XML_CIB_TAG_STATUS);		}	} else {		section_name = crm_strdup(section);		result = updateList(tmpCib, input, failed,				     cib_update_op, section);	}	crm_trace("Activating temporary CIB");	cib_update_counter(tmpCib, XML_ATTR_NUMUPDATES, FALSE);	if (result == cib_ok && activateCibXml(tmpCib, CIB_FILENAME) < 0) {		result = cib_ACTIVATION;				} else if (result != cib_ok || xml_has_children(failed)) {		if(result == cib_ok) {			result = cib_unknown;		}		crm_xml_err(failed, "CIB Update failures");	}	if (verbose || xml_has_children(failed) || result != cib_ok) {		*answer = createCibFragmentAnswer(section_name, failed);	}	cib_post_notify(op, the_update, result,			get_object_root(section_name, get_the_CIB()));	free_xml(failed);	crm_free(section_name);		return result;}gbooleanreplace_section(const char *section, crm_data_t *tmpCib, crm_data_t *fragment){	crm_data_t *cib_updates = NULL;	crm_data_t *new_section = NULL;	crm_data_t *old_section = NULL;		cib_updates = find_xml_node(fragment, XML_TAG_CIB, TRUE);	/* find the old and new versions of the section */	new_section = get_object_root(section, cib_updates);	old_section = get_object_root(section, tmpCib);		if(old_section == NULL) {		crm_err("The CIB is corrupt, cannot replace missing section %s",		       section);		return FALSE;	} else if(new_section == NULL) {		crm_err("The CIB is corrupt, cannot set section %s to nothing",		       section);		return FALSE;	}	xml_child_iter(		old_section, a_child, NULL,		free_xml_from_parent(old_section, a_child);		);	copy_in_properties(old_section, new_section);	xml_child_iter(		new_section, a_child, NULL,		add_node_copy(old_section, a_child);		);	return TRUE;}enum cib_errorsupdateList(crm_data_t *local_cib, crm_data_t *update_fragment, crm_data_t *failed,	   int operation, const char *section){	int rc = cib_ok;	crm_data_t *this_section = get_object_root(section, local_cib);	crm_data_t *cib_updates  = NULL;	crm_data_t *xml_section  = NULL;	cib_updates  = find_xml_node(update_fragment, XML_TAG_CIB, TRUE);	xml_section  = get_object_root(section, cib_updates);		if (section == NULL || xml_section == NULL) {		crm_err("Section %s not found in message."			"  CIB update is corrupt, ignoring.",			crm_str(section));		return cib_NOSECTION;	}	if(CIB_OP_NONE > operation > CIB_OP_MAX) {		crm_err("Invalid operation on section %s", crm_str(section));		return cib_operation;	}	set_node_tstamp(this_section);	xml_child_iter(		xml_section, a_child, NULL,		rc = cib_ok;		if(operation == CIB_OP_DELETE) {			rc = delete_cib_object(this_section, a_child);			update_results(failed, a_child, operation, rc);		} else if(operation == CIB_OP_MODIFY) {			rc = update_cib_object(this_section, a_child, FALSE);			update_results(failed, a_child, operation, rc);				       		} else {			rc = add_cib_object(this_section, a_child);			update_results(failed, a_child, operation, rc);		} 		);	if(rc == cib_ok && xml_has_children(failed)) {		rc = cib_unknown;	}	return rc;}crm_data_t*createCibFragmentAnswer(const char *section, crm_data_t *failed){	crm_data_t *cib = NULL;	crm_data_t *fragment = NULL;		fragment = create_xml_node(NULL, XML_TAG_FRAGMENT);	if (section == NULL		   || strlen(section) == 0		   || strcmp(XML_CIB_TAG_SECTION_ALL, section) == 0) {		cib = get_the_CIB();		if(cib != NULL) {			add_node_copy(fragment, get_the_CIB());		}			} else {		crm_data_t *obj_root = get_object_root(section, get_the_CIB());		if(obj_root != NULL) {			cib      = create_xml_node(fragment, XML_TAG_CIB);			add_node_copy(cib, obj_root);			copy_in_properties(cib, get_the_CIB());		} 	}	if (failed != NULL && xml_has_children(failed)) {		add_node_copy(fragment, failed);	}			set_xml_property_copy(fragment, XML_ATTR_SECTION, section);	set_xml_property_copy(fragment, "generated_on", cib_our_uname);	return fragment;}gbooleancheck_generation(crm_data_t *newCib, crm_data_t *oldCib){	if(cib_compare_generation(newCib, oldCib) >= 0) {		return TRUE;	}	crm_warn("Generation from update is older than the existing one");	return FALSE;} gbooleanupdate_results(	crm_data_t *failed, crm_data_t *target, int operation, int return_code){	gboolean   was_error      = FALSE;	const char *error_msg     = NULL;	const char *operation_msg = NULL;	crm_data_t *xml_node       = NULL;		operation_msg = cib_op2string(operation);    	if (return_code != cib_ok) {		error_msg = cib_error2string(return_code);		xml_node = create_xml_node(failed, XML_FAIL_TAG_CIB);		was_error = TRUE;		add_node_copy(xml_node, target);				set_xml_property_copy(			xml_node, XML_FAILCIB_ATTR_ID, ID(target));		set_xml_property_copy(			xml_node, XML_FAILCIB_ATTR_OBJTYPE, TYPE(target));		set_xml_property_copy(			xml_node, XML_FAILCIB_ATTR_OP, operation_msg);			set_xml_property_copy(			xml_node, XML_FAILCIB_ATTR_REASON, error_msg);		crm_warn("Action %s failed: %s (cde=%d)",			  operation_msg, error_msg, return_code);		} else {		crm_devel("CIB %s passed", operation_msg);	}	return was_error;}enum cib_errorsrevision_check(crm_data_t *cib_update, crm_data_t *cib_copy, int flags){	enum cib_errors rc = cib_ok;	char *revision = crm_element_value_copy(		cib_update, XML_ATTR_CIB_REVISION);	const char *cur_revision = crm_element_value(		cib_copy, XML_ATTR_CIB_REVISION);	crm_validate_data(cib_update);	crm_validate_data(cib_copy);		if(revision == NULL) {		return cib_ok;	} else if(cur_revision == NULL		  || strcmp(revision, cur_revision) > 0) {		crm_info("Updating CIB revision to %s", revision);		set_xml_property_copy(			cib_copy, XML_ATTR_CIB_REVISION, revision);	} else {		/* make sure we end up with the right value in the end */		set_xml_property_copy(			cib_update, XML_ATTR_CIB_REVISION, cur_revision);	}		if(strcmp(revision, cib_feature_revision_s) > 0) {		CRM_DEV_ASSERT(cib_is_master == FALSE);		CRM_DEV_ASSERT((flags & cib_scope_local) == 0);		if(cib_is_master) {			crm_err("Update uses an unsupported tag/feature:"				" %s vs %s",				revision, cib_feature_revision_s);			rc = cib_revision_unsupported;		} else if(flags & cib_scope_local) {			 /* an admin has forced a local change using a tag we			  * dont understand... ERROR			  */			crm_err("Local update uses an unsupported tag/feature:"				" %s vs %s",				revision, cib_feature_revision_s);			rc = cib_revision_unsupported;		}	}		crm_free(revision);	return rc;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -