Ack with minor comments (review only) Use bool instead of SaBoolT.
Variables names should follow the Google Style Guide https://google.github.io/styleguide/cppguide.html#Variable_Names So is_changed is probably better. On 22/6/18, 11:43 am, "thang.nguyen" <thang.d.ngu...@dektech.com.au> wrote: Currently changing attribute saAmfCtDefDisableRestart of SaAmfCompType object not affect to all components at runtime. Because the change does not broadcast to all nodes. Broadcast the change once it is updated. Similar fix for attribute saAmfCtDefInstantiationLevel. --- src/amf/amfd/comptype.cc | 198 ++++++++++++++++++++++++++--------------------- 1 file changed, 109 insertions(+), 89 deletions(-) diff --git a/src/amf/amfd/comptype.cc b/src/amf/amfd/comptype.cc index b6d4d6d..d0313ad 100644 --- a/src/amf/amfd/comptype.cc +++ b/src/amf/amfd/comptype.cc @@ -460,6 +460,7 @@ static void ccb_apply_modify_hdlr(const CcbUtilOperationData_t *opdata) { const SaImmAttrModificationT_2 *attr_mod; AVD_COMP_TYPE *comp_type; SaNameT comp_type_name; + SaBoolT ischanged; TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, osaf_extended_name_borrow(&opdata->objectName)); @@ -488,97 +489,116 @@ static void ccb_apply_modify_hdlr(const CcbUtilOperationData_t *opdata) { comp = comp->comp_type_list_comp_next; } - std::set<AVD_AVND *>::iterator it; - for (it = node_set.begin(); it != node_set.end(); ++it) { - int i = 0; - while ((attr_mod = opdata->param.modify.attrMods[i++]) != nullptr) { - AVSV_PARAM_INFO param; - memset(¶m, 0, sizeof(param)); - param.class_id = AVSV_SA_AMF_COMP_TYPE; - param.act = AVSV_OBJ_OPR_MOD; - param.name = opdata->objectName; - const SaImmAttrValuesT_2 *attribute = &attr_mod->modAttr; - - if (!strcmp(attribute->attrName, "saAmfCtDefCallbackTimeout")) { - SaTimeT *param_val = (SaTimeT *)attribute->attrValues[0]; - TRACE( - "saAmfCtDefCallbackTimeout to '%llu' for compType '%s' on node '%s'", - *param_val, osaf_extended_name_borrow(&opdata->objectName), - (*it)->name.c_str()); - param.value_len = sizeof(*param_val); - memcpy(param.value, param_val, param.value_len); - param.attr_id = saAmfCtDefCallbackTimeout_ID; - avd_snd_op_req_msg(avd_cb, *it, ¶m); - } else if (!strcmp(attribute->attrName, "saAmfCtDefClcCliTimeout")) { - SaTimeT *param_val = (SaTimeT *)attribute->attrValues[0]; - TRACE( - "saAmfCtDefClcCliTimeout to '%llu' for compType '%s' on node '%s'", - *param_val, osaf_extended_name_borrow(&opdata->objectName), - (*it)->name.c_str()); - param.value_len = sizeof(*param_val); - memcpy(param.value, param_val, param.value_len); - param.attr_id = saAmfCtDefClcCliTimeout_ID; - avd_snd_op_req_msg(avd_cb, *it, ¶m); - } else if (!strcmp(attribute->attrName, - "saAmfCtDefQuiescingCompleteTimeout")) { - SaTimeT *param_val = (SaTimeT *)attribute->attrValues[0]; - TRACE( - "saAmfCtDefQuiescingCompleteTimeout to '%llu' for compType '%s' on node '%s'", - *param_val, osaf_extended_name_borrow(&opdata->objectName), - (*it)->name.c_str()); - param.value_len = sizeof(*param_val); - memcpy(param.value, param_val, param.value_len); - param.attr_id = saAmfCtDefQuiescingCompleteTimeout_ID; - avd_snd_op_req_msg(avd_cb, *it, ¶m); - } else if (!strcmp(attribute->attrName, "saAmfCtDefInstantiationLevel")) { - SaUint32T param_val; - SaUint32T old_value = comp_type->saAmfCtDefInstantiationLevel; - if ((attr_mod->modType == SA_IMM_ATTR_VALUES_DELETE) || - (attribute->attrValues == nullptr)) { - param_val = 0; // Default value as per Section 8.13.1 (B0401) - } else { - param_val = *(SaUint32T *)attribute->attrValues[0]; - } - TRACE( - "saAmfCtDefInstantiationLevel to '%u' for compType '%s' on node '%s'", - param_val, osaf_extended_name_borrow(&opdata->objectName), - (*it)->name.c_str()); - param.value_len = sizeof(param_val); - memcpy(param.value, ¶m_val, param.value_len); - param.attr_id = saAmfCtDefInstantiationLevel_ID; + int i = 0; + while ((attr_mod = opdata->param.modify.attrMods[i++]) != nullptr) { + AVSV_PARAM_INFO param; + memset(¶m, 0, sizeof(param)); + param.class_id = AVSV_SA_AMF_COMP_TYPE; + param.act = AVSV_OBJ_OPR_MOD; + param.name = opdata->objectName; + const SaImmAttrValuesT_2 *attribute = &attr_mod->modAttr; + ischanged = SA_FALSE; + + if (!strcmp(attribute->attrName, "saAmfCtDefCallbackTimeout")) { + SaTimeT *param_val = (SaTimeT *)attribute->attrValues[0]; + SaTimeT old_value = comp_type->saAmfCtDefCallbackTimeout; + TRACE( + "saAmfCtDefCallbackTimeout to '%llu' for compType '%s'", + *param_val, osaf_extended_name_borrow(&opdata->objectName)); + param.value_len = sizeof(*param_val); + memcpy(param.value, param_val, param.value_len); + param.attr_id = saAmfCtDefCallbackTimeout_ID; + if (old_value != *param_val) { + comp_type->saAmfCtDefCallbackTimeout = *param_val; + ischanged = SA_TRUE; + } + } else if (!strcmp(attribute->attrName, "saAmfCtDefClcCliTimeout")) { + SaTimeT *param_val = (SaTimeT *)attribute->attrValues[0]; + SaTimeT old_value = comp_type->saAmfCtDefClcCliTimeout; + TRACE( + "saAmfCtDefClcCliTimeout to '%llu' for compType '%s'", + *param_val, osaf_extended_name_borrow(&opdata->objectName)); + param.value_len = sizeof(*param_val); + memcpy(param.value, param_val, param.value_len); + param.attr_id = saAmfCtDefClcCliTimeout_ID; + if (old_value != *param_val) { + comp_type->saAmfCtDefClcCliTimeout = *param_val; + ischanged = SA_TRUE; + } + } else if (!strcmp(attribute->attrName, + "saAmfCtDefQuiescingCompleteTimeout")) { + SaTimeT *param_val = (SaTimeT *)attribute->attrValues[0]; + SaTimeT old_value = comp_type->saAmfCtDefQuiescingCompleteTimeout; + TRACE( + "saAmfCtDefQuiescingCompleteTimeout to '%llu' for compType '%s'", + *param_val, osaf_extended_name_borrow(&opdata->objectName)); + param.value_len = sizeof(*param_val); + memcpy(param.value, param_val, param.value_len); + param.attr_id = saAmfCtDefQuiescingCompleteTimeout_ID; + if (old_value != *param_val) { + comp_type->saAmfCtDefQuiescingCompleteTimeout = *param_val; + ischanged = SA_TRUE; + } + } else if (!strcmp(attribute->attrName, "saAmfCtDefInstantiationLevel")) { + SaUint32T param_val; + SaUint32T old_value = comp_type->saAmfCtDefInstantiationLevel; + if ((attr_mod->modType == SA_IMM_ATTR_VALUES_DELETE) || + (attribute->attrValues == nullptr)) { + param_val = 0; // Default value as per Section 8.13.1 (B0401) + } else { + param_val = *(SaUint32T *)attribute->attrValues[0]; + } + TRACE( + "saAmfCtDefInstantiationLevel to '%u' for compType '%s'", + param_val, osaf_extended_name_borrow(&opdata->objectName)); + param.value_len = sizeof(param_val); + memcpy(param.value, ¶m_val, param.value_len); + param.attr_id = saAmfCtDefInstantiationLevel_ID; + if (old_value != param_val) { comp_type->saAmfCtDefInstantiationLevel = param_val; - if (old_value != param_val) avd_snd_op_req_msg(avd_cb, *it, ¶m); - } else if (!strcmp(attribute->attrName, "saAmfCtDefRecoveryOnError")) { - SaAmfRecommendedRecoveryT *param_val = - (SaAmfRecommendedRecoveryT *)attribute->attrValues[0]; - TRACE( - "saAmfCtDefRecoveryOnError to '%u' for compType '%s' on node '%s'", - *param_val, osaf_extended_name_borrow(&opdata->objectName), - (*it)->name.c_str()); - param.value_len = sizeof(*param_val); - memcpy(param.value, param_val, param.value_len); - param.attr_id = saAmfCtDefRecoveryOnError_ID; - avd_snd_op_req_msg(avd_cb, *it, ¶m); - } else if (!strcmp(attribute->attrName, "saAmfCtDefDisableRestart")) { - SaBoolT param_val; - SaUint32T old_value = comp_type->saAmfCtDefDisableRestart; - if ((attr_mod->modType == SA_IMM_ATTR_VALUES_DELETE) || - (attribute->attrValues == nullptr)) { - param_val = static_cast<SaBoolT>( - 0); // Default value as per Section 8.13.1 (B0401) - } else { - param_val = *(SaBoolT *)attribute->attrValues[0]; - } - TRACE("saAmfCtDefDisableRestart to '%u' for compType '%s' on node '%s'", - param_val, osaf_extended_name_borrow(&opdata->objectName), - (*it)->name.c_str()); - param.value_len = sizeof(param_val); - memcpy(param.value, ¶m_val, param.value_len); - param.attr_id = saAmfCtDefDisableRestart_ID; + ischanged = SA_TRUE; + } + } else if (!strcmp(attribute->attrName, "saAmfCtDefRecoveryOnError")) { + SaUint32T old_value = comp_type->saAmfCtDefRecoveryOnError; + SaAmfRecommendedRecoveryT *param_val = + (SaAmfRecommendedRecoveryT *)attribute->attrValues[0]; + TRACE( + "saAmfCtDefRecoveryOnError to '%u' for compType '%s'", + *param_val, osaf_extended_name_borrow(&opdata->objectName)); + param.value_len = sizeof(*param_val); + memcpy(param.value, param_val, param.value_len); + param.attr_id = saAmfCtDefRecoveryOnError_ID; + if (old_value != *param_val) { + comp_type->saAmfCtDefRecoveryOnError = *param_val; + ischanged = SA_TRUE; + } + } else if (!strcmp(attribute->attrName, "saAmfCtDefDisableRestart")) { + SaBoolT param_val; + SaUint32T old_value = comp_type->saAmfCtDefDisableRestart; + if ((attr_mod->modType == SA_IMM_ATTR_VALUES_DELETE) || + (attribute->attrValues == nullptr)) { + param_val = static_cast<SaBoolT>( + 0); // Default value as per Section 8.13.1 (B0401) + } else { + param_val = *(SaBoolT *)attribute->attrValues[0]; + } + TRACE("saAmfCtDefDisableRestart to '%u' for compType '%s'", + param_val, osaf_extended_name_borrow(&opdata->objectName)); + param.value_len = sizeof(param_val); + memcpy(param.value, ¶m_val, param.value_len); + param.attr_id = saAmfCtDefDisableRestart_ID; + if (old_value != param_val) { comp_type->saAmfCtDefDisableRestart = param_val; - if (old_value != param_val) avd_snd_op_req_msg(avd_cb, *it, ¶m); - } else - LOG_WA("Unexpected attribute name: %s", attribute->attrName); + ischanged = SA_TRUE; + } + } else + LOG_WA("Unexpected attribute name: %s", attribute->attrName); + + if (ischanged == SA_TRUE) { + std::set<AVD_AVND *>::iterator it; + for (it = node_set.begin(); it != node_set.end(); ++it) { + avd_snd_op_req_msg(avd_cb, *it, ¶m); + } } } } -- 2.7.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel