Bugfix: Replicated objects weren't removed on peer instances when they were removed on the source instance.

This commit is contained in:
Gunnar Beutner 2012-10-12 09:58:34 +02:00
parent a2f099e0d0
commit a5046ae7bf

View File

@ -110,6 +110,13 @@ RequestMessage ReplicationComponent::MakeObjectMessage(const DynamicObject::Ptr&
params.Set("name", object->GetName()); params.Set("name", object->GetName());
params.Set("type", object->GetType()); params.Set("type", object->GetType());
String source = object->GetSource();
if (source.IsEmpty())
source = EndpointManager::GetInstance()->GetIdentity();
params.Set("source", source);
if (includeProperties) if (includeProperties)
params.Set("update", object->BuildUpdate(sinceTx, Attribute_Replicated | Attribute_Config)); params.Set("update", object->BuildUpdate(sinceTx, Attribute_Replicated | Attribute_Config));
@ -171,6 +178,10 @@ void ReplicationComponent::RemoteObjectUpdateHandler(const Endpoint::Ptr& sender
if (!params.Get("type", &type)) if (!params.Get("type", &type))
return; return;
String source;
if (!params.Get("source", &source))
return;
Dictionary::Ptr update; Dictionary::Ptr update;
if (!params.Get("update", &update)) if (!params.Get("update", &update))
return; return;
@ -182,7 +193,7 @@ void ReplicationComponent::RemoteObjectUpdateHandler(const Endpoint::Ptr& sender
if (!object) { if (!object) {
object = DynamicObject::Create(type, update); object = DynamicObject::Create(type, update);
if (object->GetSource() == EndpointManager::GetInstance()->GetIdentity()) { if (source == EndpointManager::GetInstance()->GetIdentity()) {
/* the peer sent us an object that was originally created by us - /* the peer sent us an object that was originally created by us -
* however it was deleted locally so we have to tell the peer to destroy * however it was deleted locally so we have to tell the peer to destroy
* its copy of the object. */ * its copy of the object. */
@ -192,9 +203,9 @@ void ReplicationComponent::RemoteObjectUpdateHandler(const Endpoint::Ptr& sender
return; return;
} }
if (object->GetSource().IsEmpty()) Logger::Write(LogInformation, "replication", "Received object from source: " + source);
object->SetSource(sender->GetName());
object->SetSource(source);
object->Register(); object->Register();
} else { } else {
if (object->IsLocal()) if (object->IsLocal())