fix race condition when persisting large numbers of items

This commit is contained in:
DarthArgus
2015-10-06 01:40:57 -05:00
parent db3ed3b57a
commit 7b1f5a9991
5 changed files with 24 additions and 11 deletions
@@ -404,7 +404,7 @@ void IntangibleObject::onPermanentlyDestroyed()
* Persists this object in the database. Will also persist all the objects it
* is keeping track of.
*/
void IntangibleObject::persist()
bool IntangibleObject::persist()
{
if (isAuthoritative() && isTheater())
{
@@ -412,11 +412,11 @@ void IntangibleObject::persist()
{
// we are not finished creating our objects, prevent persistance
WARNING(true, ("IntangibleObject::persist called before all objects created"));
return;
return false;
}
if (isPersisted())
return;
return true;
ServerObject::persist();
@@ -470,9 +470,15 @@ void IntangibleObject::persist()
}
}
return true;
}
else
else {
ServerObject::persist();
return true;
}
return false;
} // IntangibleObject::persist
//------------------------------------------------------------------------------------------
@@ -44,7 +44,7 @@ public:
virtual float alter(float time);
virtual void onPermanentlyDestroyed();
virtual void persist();
virtual bool persist();
virtual bool isVisibleOnClient (const Client & client) const;
virtual void getAttributes (stdvector<std::pair<std::string, Unicode::String> >::fwd &data) const;
virtual bool onContainerAboutToTransfer(ServerObject * destination, ServerObject* transferer);
@@ -3214,11 +3214,11 @@ void ServerObject::onRemovedFromTriggerVolume(TriggerVolume & triggerVolume)
* After this function is called, changes to this object will be sent to the database.
*/
void ServerObject::persist()
bool ServerObject::persist()
{
// Do not persist buildout objects (buildout objects have negative networkIds)
if (getNetworkId() < NetworkId::cms_invalid)
return;
return false;
if (isAuthoritative())
{
@@ -3232,7 +3232,7 @@ void ServerObject::persist()
if (!contained && !isPlayerControlled() && getPosition_p() != Vector::zero)
{
WARNING_STRICT_FATAL(true, ("Tried to persist non-player object %s in a space scene away from the origin (not persisting).", getDebugInformation().c_str()));
return;
return false;
}
}
else
@@ -3257,11 +3257,15 @@ void ServerObject::persist()
PositionUpdateTracker::sendPositionUpdate(*this);
}
return true;
}
else
{
sendControllerMessageToAuthServer(CM_persistObject, 0);
}
return false;
}
// ----------------------------------------------------------------------
@@ -297,7 +297,7 @@ public:
bool isInEndBaselines() const;
bool isNeedingPobFixup() const;
bool permanentlyDestroy (DeleteReasons::Enumerator reason);
virtual void persist ();
virtual bool persist ();
virtual void onRemovingFromWorld ();
virtual void unload ();
void moveToPlayerAndUnload (const NetworkId &player);
@@ -1123,8 +1123,11 @@ jboolean JNICALL ScriptMethodsObjectCreateNamespace::persistObject(JNIEnv *env,
ServerObject* object = NULL;
if (!JavaLibrary::getObject(target, object))
return JNI_FALSE;
object->persist();
return JNI_TRUE;
if (object->persist()) {
return JNI_TRUE;
} else {
return JNI_FALSE;
}
} // JavaLibrary::persistObject
/**