When adding value set which has duplicated values into non-pure
runtime attribute (cached or persistent), the first loop (doIt=0) does
not validate in the correct way. It tries to detect duplicated
values between current values and provided values without updating
current values. So the current values remain the old values and
validation just checks on that value set. Duplicated values cannot be
dectected in provided values by current values. As a result, err is
still SA_AIS_OK even though provided values are duplicated in the first
loop.
This fix also increases performance for the previous fix. The validation
should be performed in first loop (doIt=0) instead of both loops.
---
src/imm/immnd/ImmModel.cc | 42 +++++++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 15 deletions(-)
diff --git a/src/imm/immnd/ImmModel.cc b/src/imm/immnd/ImmModel.cc
index 156c308..80ba6ef 100644
--- a/src/imm/immnd/ImmModel.cc
+++ b/src/imm/immnd/ImmModel.cc
@@ -18119,7 +18119,7 @@ SaAisErrorT ImmModel::rtObjectUpdate(
eduAtValToOs(&tmpos, &(p->attrValue.attrValue),
(SaImmValueTypeT)p->attrValue.attrValueType);
- if ((attr->mFlags & SA_IMM_ATTR_NO_DUPLICATES) &&
+ if (!doIt && (attr->mFlags & SA_IMM_ATTR_NO_DUPLICATES) &&
(multiattr->hasMatchingValue(tmpos))) {
LOG_NO(
"ERR_INVALID_PARAM: multivalued attr '%s' with "
@@ -18127,9 +18127,7 @@ SaAisErrorT ImmModel::rtObjectUpdate(
"call. Object:'%s'.", attrName.c_str(), objectName.c_str());
err = SA_AIS_ERR_INVALID_PARAM;
break; // out of for switch
- }
-
- if (doIt) {
+ } else if (doIt){
multiattr->setExtraValue(tmpos);
}
}
@@ -18147,22 +18145,36 @@ SaAisErrorT ImmModel::rtObjectUpdate(
osafassert(attrValue->isMultiValued());
ImmAttrMultiValue* multiattr = (ImmAttrMultiValue*)attrValue;
- IMMSV_EDU_ATTR_VAL_LIST* al = p->attrValue.attrMoreValues;
+ // Note: tmpMultiVal is used for validation purpose. It is only
+ // valid when doIt = 0. It holds the first value which does not
+ // exist in p->attrValue.attrMoreValues.
+ ImmAttrMultiValue tmpMultiVal;
+ if (!doIt && (attr->mFlags & SA_IMM_ATTR_NO_DUPLICATES)) {
+ eduAtValToOs(&tmpos, &(p->attrValue.attrValue),
+ (SaImmValueTypeT)p->attrValue.attrValueType);
+ tmpMultiVal = *multiattr;
+ tmpMultiVal.setExtraValue(tmpos);
+ }
+
+ IMMSV_EDU_ATTR_VAL_LIST* al = p->attrValue.attrMoreValues;
while (al) {
eduAtValToOs(&tmpos, &(al->n),
(SaImmValueTypeT)p->attrValue.attrValueType);
- if ((attr->mFlags & SA_IMM_ATTR_NO_DUPLICATES) &&
- (multiattr->hasMatchingValue(tmpos))) {
- LOG_NO(
- "ERR_INVALID_PARAM: multivalued attr '%s' with "
- "NO_DUPLICATES yet duplicate values provided in rta-update
"
- "call. Object:'%s'.", attrName.c_str(),
objectName.c_str());
- err = SA_AIS_ERR_INVALID_PARAM;
- break; // out of loop
- }
- if (doIt) {
+ if (!doIt && (attr->mFlags & SA_IMM_ATTR_NO_DUPLICATES)) {
+ if (tmpMultiVal.hasMatchingValue(tmpos)) {
+ LOG_NO(
+ "ERR_INVALID_PARAM: multivalued attr '%s' with "
+ "NO_DUPLICATES yet duplicate values provided in "
+ "rta-update call. Object:'%s'.",
+ attrName.c_str(), objectName.c_str());
+ err = SA_AIS_ERR_INVALID_PARAM;
+ break; // out of loop
+ } else {
+ tmpMultiVal.setExtraValue(tmpos);
+ }
+ } else if (doIt) {
multiattr->setExtraValue(tmpos);
}
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel