Skip to content

Commit

Permalink
Fix problem with non-existing objects in config sync updates
Browse files Browse the repository at this point in the history
refs #9851
refs #9927
refs #9081
  • Loading branch information
Michael Friedrich committed Sep 30, 2015
1 parent eb2d4f2 commit 19e7524
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions lib/remote/apilistener-configsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,36 +138,40 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin
object->SetVersion(objVersion, false, origin);
}

/* update object attributes if version was changed */
if (object && objVersion > object->GetVersion()) {
Log(LogInformation, "ApiListener")
<< "Processing config update for object '" << object->GetName()
<< "': Object version " << object->GetVersion()
<< " is older than the received version " << objVersion << ".";

Dictionary::Ptr modified_attributes = params->Get("modified_attributes");

if (modified_attributes) {
ObjectLock olock(modified_attributes);
BOOST_FOREACH(const Dictionary::Pair& kv, modified_attributes) {
/* update all modified attributes
* but do not update the object version yet.
* This triggers cluster events otherwise.
*/
object->ModifyAttribute(kv.first, kv.second, false);
}
}
if (!object)
return Empty;

/* keep the object version in sync with the sender */
object->SetVersion(objVersion, false, origin);
} else {
/* update object attributes if version was changed */
if (objVersion <= object->GetVersion()) {
Log(LogNotice, "ApiListener")
<< "Discarding config update for object '" << object->GetName()
<< "': Object version " << object->GetVersion()
<< " is more recent than the received version " << objVersion << ".";

return Empty;
}

Log(LogNotice, "ApiListener")
<< "Processing config update for object '" << object->GetName()
<< "': Object version " << object->GetVersion()
<< " is older than the received version " << objVersion << ".";

Dictionary::Ptr modified_attributes = params->Get("modified_attributes");

if (modified_attributes) {
ObjectLock olock(modified_attributes);
BOOST_FOREACH(const Dictionary::Pair& kv, modified_attributes) {
/* update all modified attributes
* but do not update the object version yet.
* This triggers cluster events otherwise.
*/
object->ModifyAttribute(kv.first, kv.second, false);
}
}

/* keep the object version in sync with the sender */
object->SetVersion(objVersion, false, origin);

return Empty;
}

Expand Down

0 comments on commit 19e7524

Please sign in to comment.