From 0af880eb0001e7b166984adfc9950b06667e78ed Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Mon, 20 Jan 2014 08:10:25 +0100 Subject: [PATCH 1/8] Simplify ObjectStore method naming --- co/localNode.cpp | 28 +++++++------- co/localNode.h | 4 +- co/objectStore.cpp | 96 +++++++++++++++++++++++----------------------- co/objectStore.h | 56 +++++++++++++-------------- 4 files changed, 91 insertions(+), 93 deletions(-) diff --git a/co/localNode.cpp b/co/localNode.cpp index 9160d7c8a..4178560c5 100644 --- a/co/localNode.cpp +++ b/co/localNode.cpp @@ -1,5 +1,5 @@ -/* Copyright (c) 2005-2013, Stefan Eilemann +/* Copyright (c) 2005-2014, Stefan Eilemann * 2010, Cedric Stalder * 2012, Daniel Nachbaur * @@ -659,20 +659,20 @@ void LocalNode::disableSendOnRegister() bool LocalNode::registerObject( Object* object ) { - return _impl->objectStore->registerObject( object ); + return _impl->objectStore->register_( object ); } void LocalNode::deregisterObject( Object* object ) { - _impl->objectStore->deregisterObject( object ); + _impl->objectStore->deregister( object ); } f_bool_t LocalNode::mapObject( Object* object, const UUID& id, NodePtr master, const uint128_t& version ) { - const uint32_t request = _impl->objectStore->mapObjectNB( object, id, - version, master ); - const FuturebImpl::Func& func = boost::bind( &ObjectStore::mapObjectSync, + const uint32_t request = _impl->objectStore->mapNB( object, id, version, + master ); + const FuturebImpl::Func& func = boost::bind( &ObjectStore::mapSync, _impl->objectStore, request ); return f_bool_t( new FuturebImpl( func )); } @@ -680,27 +680,27 @@ f_bool_t LocalNode::mapObject( Object* object, const UUID& id, NodePtr master, uint32_t LocalNode::mapObjectNB( Object* object, const UUID& id, const uint128_t& version ) { - return _impl->objectStore->mapObjectNB( object, id, version, 0 ); + return _impl->objectStore->mapNB( object, id, version, 0 ); } uint32_t LocalNode::mapObjectNB( Object* object, const UUID& id, const uint128_t& version, NodePtr master ) { - return _impl->objectStore->mapObjectNB( object, id, version, master ); + return _impl->objectStore->mapNB( object, id, version, master ); } bool LocalNode::mapObjectSync( const uint32_t requestID ) { - return _impl->objectStore->mapObjectSync( requestID ); + return _impl->objectStore->mapSync( requestID ); } f_bool_t LocalNode::syncObject( Object* object, NodePtr master, const UUID& id, const uint32_t instanceID ) { - const uint32_t request = _impl->objectStore->syncObjectNB( object, master, - id, instanceID ); - const FuturebImpl::Func& func = boost::bind( &ObjectStore::syncObjectSync, + const uint32_t request = _impl->objectStore->syncNB( object, master, id, + instanceID ); + const FuturebImpl::Func& func = boost::bind( &ObjectStore::syncSync, _impl->objectStore, request, object ); return f_bool_t( new FuturebImpl( func )); @@ -708,12 +708,12 @@ f_bool_t LocalNode::syncObject( Object* object, NodePtr master, const UUID& id, void LocalNode::unmapObject( Object* object ) { - _impl->objectStore->unmapObject( object ); + _impl->objectStore->unmap( object ); } void LocalNode::swapObject( Object* oldObject, Object* newObject ) { - _impl->objectStore->swapObject( oldObject, newObject ); + _impl->objectStore->swap( oldObject, newObject ); } void LocalNode::objectPush( const uint128_t& groupID, diff --git a/co/localNode.h b/co/localNode.h index a90e12e5e..9ad7a1081 100644 --- a/co/localNode.h +++ b/co/localNode.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2005-2013, Stefan Eilemann +/* Copyright (c) 2005-2014, Stefan Eilemann * 2010, Cedric Stalder * 2012, Daniel Nachbaur * @@ -295,7 +295,7 @@ class LocalNode : public lunchbox::RequestHandler, public Node, */ CO_API f_bool_t syncObject( Object* object, NodePtr master, const UUID& id, - const uint32_t instanceID=CO_INSTANCE_ALL ); + const uint32_t instanceID = CO_INSTANCE_ALL ); /** * Unmap a mapped object. * diff --git a/co/objectStore.cpp b/co/objectStore.cpp index f3b9a097e..3e41caff1 100644 --- a/co/objectStore.cpp +++ b/co/objectStore.cpp @@ -1,5 +1,5 @@ -/* Copyright (c) 2005-2013, Stefan Eilemann +/* Copyright (c) 2005-2014, Stefan Eilemann * 2010, Cedric Stalder * 2011-2012, Daniel Nachbaur * @@ -45,7 +45,7 @@ namespace co { -typedef CommandFunc CmdFunc; +typedef CommandFunc< ObjectStore > CmdFunc; ObjectStore::ObjectStore( LocalNode* localNode, a_ssize_t* counters ) : _localNode( localNode ) @@ -62,23 +62,23 @@ ObjectStore::ObjectStore( LocalNode* localNode, a_ssize_t* counters ) localNode->_registerCommand( CMD_NODE_FIND_MASTER_NODE_ID_REPLY, CmdFunc( this, &ObjectStore::_cmdFindMasterNodeIDReply ), 0 ); localNode->_registerCommand( CMD_NODE_ATTACH_OBJECT, - CmdFunc( this, &ObjectStore::_cmdAttachObject ), 0 ); + CmdFunc( this, &ObjectStore::_cmdAttach ), 0 ); localNode->_registerCommand( CMD_NODE_DETACH_OBJECT, - CmdFunc( this, &ObjectStore::_cmdDetachObject ), 0 ); + CmdFunc( this, &ObjectStore::_cmdDetach ), 0 ); localNode->_registerCommand( CMD_NODE_REGISTER_OBJECT, - CmdFunc( this, &ObjectStore::_cmdRegisterObject ), queue ); + CmdFunc( this, &ObjectStore::_cmdRegister ), queue ); localNode->_registerCommand( CMD_NODE_DEREGISTER_OBJECT, - CmdFunc( this, &ObjectStore::_cmdDeregisterObject ), queue ); + CmdFunc( this, &ObjectStore::_cmdDeregister ), queue ); localNode->_registerCommand( CMD_NODE_MAP_OBJECT, - CmdFunc( this, &ObjectStore::_cmdMapObject ), queue ); + CmdFunc( this, &ObjectStore::_cmdMap ), queue ); localNode->_registerCommand( CMD_NODE_MAP_OBJECT_SUCCESS, - CmdFunc( this, &ObjectStore::_cmdMapObjectSuccess ), 0 ); + CmdFunc( this, &ObjectStore::_cmdMapSuccess ), 0 ); localNode->_registerCommand( CMD_NODE_MAP_OBJECT_REPLY, - CmdFunc( this, &ObjectStore::_cmdMapObjectReply ), 0 ); + CmdFunc( this, &ObjectStore::_cmdMapReply ), 0 ); localNode->_registerCommand( CMD_NODE_UNMAP_OBJECT, - CmdFunc( this, &ObjectStore::_cmdUnmapObject ), 0 ); + CmdFunc( this, &ObjectStore::_cmdUnmap ), 0 ); localNode->_registerCommand( CMD_NODE_UNSUBSCRIBE_OBJECT, - CmdFunc( this, &ObjectStore::_cmdUnsubscribeObject ), queue ); + CmdFunc( this, &ObjectStore::_cmdUnsubscribe ), queue ); localNode->_registerCommand( CMD_NODE_OBJECT_INSTANCE, CmdFunc( this, &ObjectStore::_cmdInstance ), 0 ); localNode->_registerCommand( CMD_NODE_OBJECT_INSTANCE_MAP, @@ -94,11 +94,11 @@ ObjectStore::ObjectStore( LocalNode* localNode, a_ssize_t* counters ) localNode->_registerCommand( CMD_NODE_REMOVE_NODE, CmdFunc( this, &ObjectStore::_cmdRemoveNode ), queue ); localNode->_registerCommand( CMD_NODE_OBJECT_PUSH, - CmdFunc( this, &ObjectStore::_cmdObjectPush ), queue ); + CmdFunc( this, &ObjectStore::_cmdPush ), queue ); localNode->_registerCommand( CMD_NODE_SYNC_OBJECT, - CmdFunc( this, &ObjectStore::_cmdSyncObject ), queue ); + CmdFunc( this, &ObjectStore::_cmdSync ), queue ); localNode->_registerCommand( CMD_NODE_SYNC_OBJECT_REPLY, - CmdFunc( this, &ObjectStore::_cmdSyncObjectReply ), 0 ); + CmdFunc( this, &ObjectStore::_cmdSyncReply ), 0 ); } ObjectStore::~ObjectStore() @@ -218,8 +218,8 @@ NodeID ObjectStore::findMasterNodeID( const UUID& identifier ) //--------------------------------------------------------------------------- // object mapping //--------------------------------------------------------------------------- -void ObjectStore::attachObject( Object* object, const UUID& id, - const uint32_t instanceID ) +void ObjectStore::attach( Object* object, const UUID& id, + const uint32_t instanceID ) { LBASSERT( object ); LB_TS_NOT_THREAD( _receiverThread ); @@ -246,8 +246,8 @@ uint32_t _genNextID( lunchbox::a_int32_t& val ) } } -void ObjectStore::_attachObject( Object* object, const UUID& id, - const uint32_t inInstanceID ) +void ObjectStore::_attach( Object* object, const UUID& id, + const uint32_t inInstanceID ) { LBASSERT( object ); LB_TS_THREAD( _receiverThread ); @@ -275,7 +275,7 @@ void ObjectStore::_attachObject( Object* object, const UUID& id, << static_cast< void* >( object ) << std::endl; } -void ObjectStore::detachObject( Object* object ) +void ObjectStore::detach( Object* object ) { LBASSERT( object ); LB_TS_NOT_THREAD( _receiverThread ); @@ -286,7 +286,7 @@ void ObjectStore::detachObject( Object* object ) _localNode->waitRequest( requestID ); } -void ObjectStore::swapObject( Object* oldObject, Object* newObject ) +void ObjectStore::swap( Object* oldObject, Object* newObject ) { LBASSERT( newObject ); LBASSERT( oldObject ); @@ -316,7 +316,7 @@ void ObjectStore::swapObject( Object* oldObject, Object* newObject ) *j = newObject; } -void ObjectStore::_detachObject( Object* object ) +void ObjectStore::_detach( Object* object ) { // check also _cmdUnmapObject when modifying! LBASSERT( object ); @@ -346,8 +346,8 @@ void ObjectStore::_detachObject( Object* object ) return; } -uint32_t ObjectStore::mapObjectNB( Object* object, const UUID& id, - const uint128_t& version, NodePtr master ) +uint32_t ObjectStore::mapNB( Object* object, const UUID& id, + const uint128_t& version, NodePtr master ) { LB_TS_NOT_THREAD( _receiverThread ); LBLOG( LOG_OBJECTS ) @@ -418,7 +418,7 @@ bool ObjectStore::_checkInstanceCache( const UUID& id, uint128_t& from, return true; } -bool ObjectStore::mapObjectSync( const uint32_t requestID ) +bool ObjectStore::mapSync( const uint32_t requestID ) { if( requestID == LB_UNDEFINED_UINT32 ) return false; @@ -441,8 +441,8 @@ bool ObjectStore::mapObjectSync( const uint32_t requestID ) return mapped; } -uint32_t ObjectStore::syncObjectNB( Object* object, NodePtr master, - const UUID& id, const uint32_t instanceID ) +uint32_t ObjectStore::syncNB( Object* object, NodePtr master, const UUID& id, + const uint32_t instanceID ) { LB_TS_NOT_THREAD( _receiverThread ); LBLOG( LOG_OBJECTS ) @@ -499,7 +499,7 @@ uint32_t ObjectStore::syncObjectNB( Object* object, NodePtr master, return requestID; } -bool ObjectStore::syncObjectSync( const uint32_t requestID, Object* object ) +bool ObjectStore::syncSync( const uint32_t requestID, Object* object ) { if( requestID == LB_UNDEFINED_UINT32 ) return false; @@ -528,7 +528,7 @@ bool ObjectStore::syncObjectSync( const uint32_t requestID, Object* object ) return true; } -void ObjectStore::unmapObject( Object* object ) +void ObjectStore::unmap( Object* object ) { LBASSERT( object ); if( !object->isAttached( )) // not registered @@ -565,12 +565,12 @@ void ObjectStore::unmapObject( Object* object ) } // no unsubscribe sent: Detach directly - detachObject( object ); + detach( object ); object->setupChangeManager( Object::NONE, false, 0, CO_INSTANCE_INVALID ); object->notifyDetached(); } -bool ObjectStore::registerObject( Object* object ) +bool ObjectStore::register_( Object* object ) { LBASSERT( object ); LBASSERT( !object->isAttached( )); @@ -581,7 +581,7 @@ bool ObjectStore::registerObject( Object* object ) object->notifyAttach(); object->setupChangeManager( object->getChangeType(), true, _localNode, CO_INSTANCE_INVALID ); - attachObject( object, id, CO_INSTANCE_INVALID ); + attach( object, id, CO_INSTANCE_INVALID ); if( Global::getIAttribute( Global::IATTR_NODE_SEND_QUEUE_SIZE ) > 0 ) _localNode->send( CMD_NODE_REGISTER_OBJECT ) << object; @@ -592,7 +592,7 @@ bool ObjectStore::registerObject( Object* object ) return true; } -void ObjectStore::deregisterObject( Object* object ) +void ObjectStore::deregister( Object* object ) { LBASSERT( object ); if( !object->isAttached( )) // not registered @@ -612,7 +612,7 @@ void ObjectStore::deregisterObject( Object* object ) } const UUID id = object->getID(); - detachObject( object ); + detach( object ); object->setupChangeManager( Object::NONE, true, 0, CO_INSTANCE_INVALID ); if( _instanceCache ) _instanceCache->erase( id ); @@ -748,7 +748,7 @@ bool ObjectStore::_cmdFindMasterNodeIDReply( ICommand& command ) return true; } -bool ObjectStore::_cmdAttachObject( ICommand& command ) +bool ObjectStore::_cmdAttach( ICommand& command ) { LB_TS_THREAD( _receiverThread ); LBLOG( LOG_OBJECTS ) << "Cmd attach object " << command << std::endl; @@ -759,12 +759,12 @@ bool ObjectStore::_cmdAttachObject( ICommand& command ) Object* object = static_cast< Object* >( _localNode->getRequestData( requestID )); - _attachObject( object, objectID, instanceID ); + _attach( object, objectID, instanceID ); _localNode->serveRequest( requestID ); return true; } -bool ObjectStore::_cmdDetachObject( ICommand& command ) +bool ObjectStore::_cmdDetach( ICommand& command ) { LB_TS_THREAD( _receiverThread ); LBLOG( LOG_OBJECTS ) << "Cmd detach object " << command << std::endl; @@ -784,7 +784,7 @@ bool ObjectStore::_cmdDetachObject( ICommand& command ) Object* object = *j; if( object->getInstanceID() == instanceID ) { - _detachObject( object ); + _detach( object ); break; } } @@ -795,7 +795,7 @@ bool ObjectStore::_cmdDetachObject( ICommand& command ) return true; } -bool ObjectStore::_cmdRegisterObject( ICommand& command ) +bool ObjectStore::_cmdRegister( ICommand& command ) { LB_TS_THREAD( _commandThread ); if( _sendOnRegister <= 0 ) @@ -821,7 +821,7 @@ bool ObjectStore::_cmdRegisterObject( ICommand& command ) return true; } -bool ObjectStore::_cmdDeregisterObject( ICommand& command ) +bool ObjectStore::_cmdDeregister( ICommand& command ) { LB_TS_THREAD( _commandThread ); LBLOG( LOG_OBJECTS ) << "Cmd deregister object " << command << std::endl; @@ -843,7 +843,7 @@ bool ObjectStore::_cmdDeregisterObject( ICommand& command ) return true; } -bool ObjectStore::_cmdMapObject( ICommand& cmd ) +bool ObjectStore::_cmdMap( ICommand& cmd ) { LB_TS_THREAD( _commandThread ); @@ -889,7 +889,7 @@ bool ObjectStore::_cmdMapObject( ICommand& cmd ) return true; } -bool ObjectStore::_cmdMapObjectSuccess( ICommand& command ) +bool ObjectStore::_cmdMapSuccess( ICommand& command ) { LB_TS_THREAD( _receiverThread ); @@ -917,11 +917,11 @@ bool ObjectStore::_cmdMapObjectSuccess( ICommand& command ) object->setupChangeManager( Object::ChangeType( changeType ), false, _localNode, masterInstanceID ); - _attachObject( object, objectID, instanceID ); + _attach( object, objectID, instanceID ); return true; } -bool ObjectStore::_cmdMapObjectReply( ICommand& command ) +bool ObjectStore::_cmdMapReply( ICommand& command ) { LB_TS_THREAD( _receiverThread ); @@ -981,7 +981,7 @@ bool ObjectStore::_cmdMapObjectReply( ICommand& command ) return true; } -bool ObjectStore::_cmdUnsubscribeObject( ICommand& command ) +bool ObjectStore::_cmdUnsubscribe( ICommand& command ) { LB_TS_THREAD( _commandThread ); LBLOG( LOG_OBJECTS ) << "Cmd unsubscribe object " << command << std::endl; @@ -1016,7 +1016,7 @@ bool ObjectStore::_cmdUnsubscribeObject( ICommand& command ) return true; } -bool ObjectStore::_cmdUnmapObject( ICommand& command ) +bool ObjectStore::_cmdUnmap( ICommand& command ) { LB_TS_THREAD( _receiverThread ); LBLOG( LOG_OBJECTS ) << "Cmd unmap object " << command << std::endl; @@ -1045,7 +1045,7 @@ bool ObjectStore::_cmdUnmapObject( ICommand& command ) return true; } -bool ObjectStore::_cmdSyncObject( ICommand& cmd ) +bool ObjectStore::_cmdSync( ICommand& cmd ) { LB_TS_THREAD( _commandThread ); MasterCMCommand command( cmd ); @@ -1104,7 +1104,7 @@ bool ObjectStore::_cmdSyncObject( ICommand& cmd ) return true; } -bool ObjectStore::_cmdSyncObjectReply( ICommand& command ) +bool ObjectStore::_cmdSyncReply( ICommand& command ) { LB_TS_THREAD( _receiverThread ); @@ -1278,7 +1278,7 @@ bool ObjectStore::_cmdRemoveNode( ICommand& command ) return true; } -bool ObjectStore::_cmdObjectPush( ICommand& command ) +bool ObjectStore::_cmdPush( ICommand& command ) { LB_TS_THREAD( _commandThread ); diff --git a/co/objectStore.h b/co/objectStore.h index d5a5dbe98..f411c2659 100644 --- a/co/objectStore.h +++ b/co/objectStore.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2005-2013, Stefan Eilemann +/* Copyright (c) 2005-2014, Stefan Eilemann * 2010, Cedric Stalder * 2012, Daniel Nachbaur * @@ -85,35 +85,35 @@ class ObjectStore : public Dispatcher * @param object the object instance. * @return true if the object was registered, false otherwise. */ - bool registerObject( Object* object ); + bool register_( Object* object ); /** * Deregister a distributed object. * * @param object the object instance. */ - virtual void deregisterObject( Object* object ); + void deregister( Object* object ); /** Start mapping a distributed object. */ - uint32_t mapObjectNB( Object* object, const UUID& id, - const uint128_t& version, NodePtr master ); + uint32_t mapNB( Object* object, const UUID& id, const uint128_t& version, + NodePtr master ); /** Finalize the mapping of a distributed object. */ - bool mapObjectSync( const uint32_t requestID ); + bool mapSync( const uint32_t requestID ); /** Start synchronizing an object. */ - uint32_t syncObjectNB( Object* object, NodePtr master, const UUID& id, - const uint32_t instanceID ); + uint32_t syncNB( Object* object, NodePtr master, const UUID& id, + const uint32_t instanceID ); /** Finalize the synchronizatin of a distributed object. */ - bool syncObjectSync( const uint32_t requestID, Object* object ); + bool syncSync( const uint32_t requestID, Object* object ); /** * Unmap a mapped object. * * @param object the mapped object. */ - void unmapObject( Object* object ); + void unmap( Object* object ); /** * Attach an object to an identifier. @@ -127,19 +127,18 @@ class ObjectStore : public Dispatcher * @param instanceID the node-local instance identifier, or * CO_INSTANCE_INVALID if this method should generate one. */ - void attachObject( Object* object, const UUID& id, - const uint32_t instanceID ); + void attach( Object* object, const UUID& id, const uint32_t instanceID ); /** * Detach an object. * * @param object the attached object. */ - void detachObject( Object* object ); + void detach( Object* object ); /** @internal swap the existing object by a new object and keep the cm, id and instanceID. */ - void swapObject( Object* oldObject, Object* newObject ); + void swap( Object* oldObject, Object* newObject ); //@} /** @name Instance Cache. */ @@ -213,9 +212,8 @@ class ObjectStore : public Dispatcher DataIStreamQueue _pushData; //!< Object::push() queue a_ssize_t* const _counters; // LocalNode performance counters - void _attachObject( Object* object, const UUID& id, - const uint32_t instanceID ); - void _detachObject( Object* object ); + void _attach( Object* object, const UUID& id, const uint32_t instanceID ); + void _detach( Object* object ); bool _checkInstanceCache( const UUID& id, uint128_t& from, uint128_t& to, uint32_t& instanceID ); @@ -223,21 +221,21 @@ class ObjectStore : public Dispatcher /** The command handler functions. */ bool _cmdFindMasterNodeID( ICommand& command ); bool _cmdFindMasterNodeIDReply( ICommand& command ); - bool _cmdAttachObject( ICommand& command ); - bool _cmdDetachObject( ICommand& command ); - bool _cmdMapObject( ICommand& command ); - bool _cmdMapObjectSuccess( ICommand& command ); - bool _cmdMapObjectReply( ICommand& command ); - bool _cmdSyncObject( ICommand& command ); - bool _cmdSyncObjectReply( ICommand& command ); - bool _cmdUnmapObject( ICommand& command ); - bool _cmdUnsubscribeObject( ICommand& command ); + bool _cmdAttach( ICommand& command ); + bool _cmdDetach( ICommand& command ); + bool _cmdMap( ICommand& command ); + bool _cmdMapSuccess( ICommand& command ); + bool _cmdMapReply( ICommand& command ); + bool _cmdSync( ICommand& command ); + bool _cmdSyncReply( ICommand& command ); + bool _cmdUnmap( ICommand& command ); + bool _cmdUnsubscribe( ICommand& command ); bool _cmdInstance( ICommand& command ); - bool _cmdRegisterObject( ICommand& command ); - bool _cmdDeregisterObject( ICommand& command ); + bool _cmdRegister( ICommand& command ); + bool _cmdDeregister( ICommand& command ); bool _cmdDisableSendOnRegister( ICommand& command ); bool _cmdRemoveNode( ICommand& command ); - bool _cmdObjectPush( ICommand& command ); + bool _cmdPush( ICommand& command ); LB_TS_VAR( _receiverThread ); LB_TS_VAR( _commandThread ); From 691c7671a7add68bdbe71ac0397ac859ccc9d26a Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Mon, 20 Jan 2014 14:53:25 +0100 Subject: [PATCH 2/8] Fix #29: Change managers may access dangling objects --- .travis.yml | 4 ++-- co/fullMasterCM.cpp | 8 +++++--- co/fullMasterCM.h | 9 ++++----- co/nullCM.h | 8 +++++--- co/objectCM.cpp | 36 ++++++++++++++++++++++++++++-------- co/objectCM.h | 19 +++++++++++-------- co/objectStore.cpp | 8 ++------ co/staticMasterCM.h | 6 +++--- co/staticSlaveCM.h | 5 +++-- co/versionedMasterCM.cpp | 10 ++++++---- co/versionedMasterCM.h | 4 ++-- co/versionedSlaveCM.h | 7 ++++--- 12 files changed, 75 insertions(+), 49 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1abe9d5f1..dffe6c67e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,13 +7,13 @@ script: - mkdir Debug - cd Debug - cmake .. -DCI_BUILD_COMMIT=$TRAVIS_COMMIT -DCMAKE_BUILD_TYPE=Debug -DTRAVIS=1 - - env TRAVIS=1 make -j8 tests ARGS=-V + - env TRAVIS=1 make -j8 cis ARGS=-V - mkdir ../Release - git status - git --no-pager diff - cd ../Release - cmake .. -DCI_BUILD_COMMIT=$TRAVIS_COMMIT -DCMAKE_BUILD_TYPE=Release -DTRAVIS=1 - - env TRAVIS=1 make -j8 tests ARGS=-V + - env TRAVIS=1 make -j8 cis ARGS=-V - git status - git --no-pager diff before_install: diff --git a/co/fullMasterCM.cpp b/co/fullMasterCM.cpp index b681bdb4c..78bca707a 100644 --- a/co/fullMasterCM.cpp +++ b/co/fullMasterCM.cpp @@ -1,5 +1,5 @@ -/* Copyright (c) 2007-2013, Stefan Eilemann +/* Copyright (c) 2007-2014, Stefan Eilemann * 2011-2012, Daniel Nachbaur * * This file is part of Collage @@ -164,7 +164,7 @@ void FullMasterCM::_obsolete() _checkConsistency(); } -void FullMasterCM::_initSlave( const MasterCMCommand& command, +bool FullMasterCM::_initSlave( const MasterCMCommand& command, const uint128_t& /*replyVersion*/, bool replyUseCache ) { @@ -254,6 +254,7 @@ void FullMasterCM::_initSlave( const MasterCMCommand& command, LBINFO << "Cached " << _hit << "/" << _hit + _miss << " instance data transmissions" << std::endl; #endif + return true; } void FullMasterCM::_checkConsistency() const @@ -379,7 +380,7 @@ void FullMasterCM::push( const uint128_t& groupID, const uint128_t& typeID, instanceData->os.push( nodes, _object->getID(), groupID, typeID ); } -void FullMasterCM::sendSync( const MasterCMCommand& command ) +bool FullMasterCM::sendSync( const MasterCMCommand& command ) { //const uint128_t& version = command.getRequestedVersion(); const uint128_t& maxCachedVersion = command.getMaxCachedVersion(); @@ -399,6 +400,7 @@ void FullMasterCM::sendSync( const MasterCMCommand& command ) node->send( CMD_NODE_SYNC_OBJECT_REPLY, useCache /*preferMulticast*/ ) << node->getNodeID() << command.getObjectID() << command.getRequestID() << true << command.useCache() << useCache; + return true; } } diff --git a/co/fullMasterCM.h b/co/fullMasterCM.h index 1f8f6608b..163ee0e71 100644 --- a/co/fullMasterCM.h +++ b/co/fullMasterCM.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2007-2013, Stefan Eilemann +/* Copyright (c) 2007-2014, Stefan Eilemann * 2011-2012, Daniel Nachbaur * * This file is part of Collage @@ -45,7 +45,7 @@ namespace co uint128_t commit( const uint32_t incarnation ) override; void push( const uint128_t& groupID, const uint128_t& typeID, const Nodes& nodes ) override; - void sendSync( const MasterCMCommand& command ) override; + bool sendSync( const MasterCMCommand& command ) override; /** @name Versioning */ //@{ @@ -66,9 +66,8 @@ namespace co uint32_t commitCount; }; - void _initSlave( const MasterCMCommand& command, - const uint128_t& replyVersion, - bool replyUseCache ) override; + bool _initSlave( const MasterCMCommand&, const uint128_t&, + bool ) override; InstanceData* _newInstanceData(); void _addInstanceData( InstanceData* data ); diff --git a/co/nullCM.h b/co/nullCM.h index 8716a8a02..e96fc3256 100644 --- a/co/nullCM.h +++ b/co/nullCM.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2007-2013, Stefan Eilemann +/* Copyright (c) 2007-2014, Stefan Eilemann * 2011-2012, Daniel Nachbaur * * This file is part of Collage @@ -41,7 +41,8 @@ namespace co void push( const uint128_t&, const uint128_t&, const Nodes& ) override { LBDONTCALL; } - void sendSync( const MasterCMCommand& ) override { LBDONTCALL; } + bool sendSync( const MasterCMCommand& ) override + { LBDONTCALL; return false; } uint128_t getHeadVersion() const override { return VERSION_NONE; } @@ -50,7 +51,8 @@ namespace co uint32_t getMasterInstanceID() const override { LBDONTCALL; return CO_INSTANCE_INVALID; } - void addSlave( const MasterCMCommand& ) override { LBDONTCALL; } + bool addSlave( const MasterCMCommand& ) override + { LBDONTCALL; return false; } void removeSlaves( NodePtr ) override { LBDONTCALL; } private: diff --git a/co/objectCM.cpp b/co/objectCM.cpp index 3137cccd3..2477f2bf4 100644 --- a/co/objectCM.cpp +++ b/co/objectCM.cpp @@ -41,6 +41,12 @@ ObjectCM::ObjectCM( Object* object ) : _object( object ) {} +ObjectCM::~ObjectCM() +{ + lunchbox::ScopedFastWrite mutex( _lock ); + _object = 0; +} + void ObjectCM::push( const uint128_t& groupID, const uint128_t& typeID, const Nodes& nodes ) { @@ -63,9 +69,15 @@ void ObjectCM::push( const uint128_t& groupID, const uint128_t& typeID, os.disable(); // handled by remote recv thread } -void ObjectCM::sendSync( const MasterCMCommand& command ) +bool ObjectCM::sendSync( const MasterCMCommand& command ) { - LBASSERT( _object ); + lunchbox::ScopedFastWrite mutex( _lock ); + if( !_object ) + { + LBWARN << "Sync from detached object requested" << std::endl; + return false; + } + const uint128_t& maxCachedVersion = command.getMaxCachedVersion(); const bool useCache = command.useCache() && @@ -83,10 +95,10 @@ void ObjectCM::sendSync( const MasterCMCommand& command ) node->send( CMD_NODE_SYNC_OBJECT_REPLY, useCache /*preferMulticast*/ ) << node->getNodeID() << command.getObjectID() << command.getRequestID() << true << command.useCache() << useCache; - + return true; } -void ObjectCM::_addSlave( const MasterCMCommand& command, +bool ObjectCM::_addSlave( const MasterCMCommand& command, const uint128_t& version ) { LBASSERT( version != VERSION_NONE ); @@ -100,15 +112,15 @@ void ObjectCM::_addSlave( const MasterCMCommand& command, _sendMapSuccess( command, false /* mc */ ); _sendEmptyVersion( command, VERSION_NONE, false /* mc */ ); _sendMapReply( command, VERSION_NONE, true, false, false /* mc */ ); - return; + return true; } const bool replyUseCache = command.useCache() && (command.getMasterInstanceID() == _object->getInstanceID( )); - _initSlave( command, version, replyUseCache ); + return _initSlave( command, version, replyUseCache ); } -void ObjectCM::_initSlave( const MasterCMCommand& command, +bool ObjectCM::_initSlave( const MasterCMCommand& command, const uint128_t& replyVersion, bool replyUseCache ) { #if 0 @@ -133,7 +145,14 @@ void ObjectCM::_initSlave( const MasterCMCommand& command, #endif _sendMapSuccess( command, false ); _sendMapReply( command, replyVersion, true, replyUseCache, false ); - return; + return true; + } + + lunchbox::ScopedFastWrite mutex( _lock ); + if( !_object ) + { + LBWARN << "Map to detached object requested" << std::endl; + return false; } #ifdef CO_INSTRUMENT_MULTICAST @@ -154,6 +173,7 @@ void ObjectCM::_initSlave( const MasterCMCommand& command, _sendEmptyVersion( command, replyVersion, true /* mc */ ); _sendMapReply( command, replyVersion, true, replyUseCache, true ); + return true; } void ObjectCM::_sendMapSuccess( const MasterCMCommand& command, diff --git a/co/objectCM.h b/co/objectCM.h index 925528c42..86f3246cc 100644 --- a/co/objectCM.h +++ b/co/objectCM.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2007-2013, Stefan Eilemann +/* Copyright (c) 2007-2014, Stefan Eilemann * 2011-2012, Daniel Nachbaur * * This file is part of Collage @@ -49,7 +49,9 @@ class ObjectCM : public Dispatcher, public lunchbox::Referenced public: /** Construct a new change manager. */ ObjectCM( Object* object ); - virtual ~ObjectCM() {} + + /** Destruct this change manager. */ + virtual ~ObjectCM(); /** Initialize the change manager. */ virtual void init() = 0; @@ -64,8 +66,9 @@ class ObjectCM : public Dispatcher, public lunchbox::Referenced * Synchronize an instance to the managed object. * * @param command the command initiating the sync. + * @return true on success, false otherwise. */ - virtual void sendSync( const MasterCMCommand& command ); + virtual bool sendSync( const MasterCMCommand& command ); /** * Commit a new version. @@ -125,7 +128,7 @@ class ObjectCM : public Dispatcher, public lunchbox::Referenced * * @param command the subscribe command initiating the add. */ - virtual void addSlave( const MasterCMCommand& command ) = 0; + virtual bool addSlave( const MasterCMCommand& command ) = 0; /** * Remove a subscribed slave. @@ -166,16 +169,16 @@ class ObjectCM : public Dispatcher, public lunchbox::Referenced static ObjectCMPtr ZERO; protected: - /** The managed object. */ - Object* _object; + Object* _object; //!< The managed object. + lunchbox::SpinLock _lock; //!< Protects unbuffered operations on _object #ifdef CO_INSTRUMENT_MULTICAST static lunchbox::a_int32_t _hit; static lunchbox::a_int32_t _miss; #endif - void _addSlave( const MasterCMCommand& command, const uint128_t& version ); - virtual void _initSlave( const MasterCMCommand& command, + bool _addSlave( const MasterCMCommand& command, const uint128_t& version ); + virtual bool _initSlave( const MasterCMCommand& command, const uint128_t& replyVersion, bool replyUseCache ); void _sendMapSuccess( const MasterCMCommand& command, diff --git a/co/objectStore.cpp b/co/objectStore.cpp index 3e41caff1..559b44269 100644 --- a/co/objectStore.cpp +++ b/co/objectStore.cpp @@ -874,9 +874,7 @@ bool ObjectStore::_cmdMap( ICommand& cmd ) } } - if( masterCM ) - masterCM->addSlave( command ); - else + if( !masterCM || !masterCM->addSlave( command )) { LBWARN << "Can't find master object to map " << id << std::endl; NodePtr node = command.getNode(); @@ -1092,9 +1090,7 @@ bool ObjectStore::_cmdSync( ICommand& cmd ) LBWARN << "Can't find object to sync " << id << ", no object with identifier" << std::endl; } - if( cm ) - cm->sendSync( command ); - else + if( !cm || !cm->sendSync( command )) { NodePtr node = command.getNode(); node->send( CMD_NODE_SYNC_OBJECT_REPLY ) diff --git a/co/staticMasterCM.h b/co/staticMasterCM.h index 43d0d4698..af662ace8 100644 --- a/co/staticMasterCM.h +++ b/co/staticMasterCM.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2007-2013, Stefan Eilemann +/* Copyright (c) 2007-2014, Stefan Eilemann * 2010, Cedric Stalder * 2011-2012, Daniel Nachbaur * @@ -56,8 +56,8 @@ namespace co uint32_t getMasterInstanceID() const override { LBDONTCALL; return CO_INSTANCE_INVALID; } - void addSlave( const MasterCMCommand& command ) override - { ObjectCM::_addSlave( command, VERSION_FIRST ); } + bool addSlave( const MasterCMCommand& command ) override + { return _addSlave( command, VERSION_FIRST ); } void removeSlaves( NodePtr ) override { /* NOP */} }; } diff --git a/co/staticSlaveCM.h b/co/staticSlaveCM.h index f72e14721..aae1fa812 100644 --- a/co/staticSlaveCM.h +++ b/co/staticSlaveCM.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2007-2013, Stefan Eilemann +/* Copyright (c) 2007-2014, Stefan Eilemann * 2011-2012, Daniel Nachbaur * * This file is part of Collage @@ -50,7 +50,8 @@ namespace co uint32_t getMasterInstanceID() const override { return CO_INSTANCE_INVALID; } - void addSlave( const MasterCMCommand& ) override { LBDONTCALL; } + bool addSlave( const MasterCMCommand& ) override + { LBDONTCALL; return false; } void removeSlaves( NodePtr ) override {} void applyMapData( const uint128_t& version ) override; diff --git a/co/versionedMasterCM.cpp b/co/versionedMasterCM.cpp index 8317061f4..26ef7702a 100644 --- a/co/versionedMasterCM.cpp +++ b/co/versionedMasterCM.cpp @@ -1,5 +1,5 @@ -/* Copyright (c) 2010-2013, Stefan Eilemann +/* Copyright (c) 2010-2014, Stefan Eilemann * 2012, Daniel Nachbaur * * This file is part of Collage @@ -101,11 +101,14 @@ uint128_t VersionedMasterCM::_apply( ObjectDataIStream* is ) return version; } -void VersionedMasterCM::addSlave( const MasterCMCommand& command ) +bool VersionedMasterCM::addSlave( const MasterCMCommand& command ) { LB_TS_THREAD( _cmdThread ); Mutex mutex( _slaves ); + if( !_addSlave( command, _version )) + return false; + SlaveData data; data.node = command.getNode(); data.instanceID = command.getInstanceID(); @@ -120,8 +123,7 @@ void VersionedMasterCM::addSlave( const MasterCMCommand& command ) _slaves->push_back( data.node ); lunchbox::usort( *_slaves ); - - ObjectCM::_addSlave( command, _version ); + return true; } void VersionedMasterCM::removeSlave( NodePtr node, const uint32_t instanceID ) diff --git a/co/versionedMasterCM.h b/co/versionedMasterCM.h index 42515195a..f34d4e52f 100644 --- a/co/versionedMasterCM.h +++ b/co/versionedMasterCM.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2010-2013, Stefan Eilemann +/* Copyright (c) 2010-2014, Stefan Eilemann * 2012, Daniel Nachbaur * * This file is part of Collage @@ -61,7 +61,7 @@ namespace co uint32_t getMasterInstanceID() const override { LBDONTCALL; return CO_INSTANCE_INVALID; } - void addSlave( const MasterCMCommand& command ) override; + bool addSlave( const MasterCMCommand& command ) override; void removeSlave( NodePtr node, const uint32_t instanceID ) override; void removeSlaves( NodePtr node ) override; const Nodes getSlaveNodes() const override diff --git a/co/versionedSlaveCM.h b/co/versionedSlaveCM.h index 7360f416c..66b6c016f 100644 --- a/co/versionedSlaveCM.h +++ b/co/versionedSlaveCM.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2007-2013, Stefan Eilemann +/* Copyright (c) 2007-2014, Stefan Eilemann * 2011-2012, Daniel Nachbaur * * This file is part of Collage @@ -62,12 +62,13 @@ namespace co void setMasterNode( NodePtr node ) override { _master = node; } NodePtr getMasterNode() override { return _master; } - void addSlave( const MasterCMCommand& ) override { LBDONTCALL; } + bool addSlave( const MasterCMCommand& ) override + { LBDONTCALL; return false; } void removeSlaves( NodePtr ) override {} void applyMapData( const uint128_t& version ) override; void addInstanceDatas( const ObjectDataIStreamDeque&, - const uint128_t& startVersion ) override; + const uint128_t& startVersion ) override; private: /** The current version. */ uint128_t _version; From 1639175d493ed3c3af514c710a750caf077f9ba2 Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Mon, 20 Jan 2014 15:32:26 +0100 Subject: [PATCH 3/8] UDT: set OS-chosen port after bind() in description --- co/udtConnection.cpp | 43 +++++++++++++++++++++++-------------------- tests/connection.cpp | 4 ++-- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/co/udtConnection.cpp b/co/udtConnection.cpp index 46fffe8e0..51f982af7 100644 --- a/co/udtConnection.cpp +++ b/co/udtConnection.cpp @@ -331,7 +331,8 @@ bool UDTConnection::connect( ) if( UDT::ERROR == UDT::connect( _udt, &address, sizeof( address ))) { - LBERROR << UDTLASTERROR( "UDT::connect" ) << std::endl; + LBERROR << UDTLASTERROR( "UDT::connect" ) << " to " << description + << std::endl; goto err; } @@ -361,50 +362,53 @@ bool UDTConnection::connect( ) } // caller: application -bool UDTConnection::listen( ) +bool UDTConnection::listen() { - struct sockaddr address; - - ConstConnectionDescriptionPtr description = getDescription(); + ConnectionDescriptionPtr description = _getDescription(); LBASSERT( CONNECTIONTYPE_UDT == description->type ); if( !isClosed( )) return false; _setState( STATE_CONNECTING ); + struct sockaddr address; if( !_parseAddress( description, address, true )) - goto err; + return false; LBASSERT( UDT::INVALID_SOCK == _udt ); _udt = UDT::socket( AF_INET, SOCK_STREAM, 0 ); if( UDT::INVALID_SOCK == _udt ) { LBERROR << UDTLASTERROR( "UDT::socket" ) << std::endl; - goto err; + return false; } if( !tuneSocket( )) - goto err; + return false; if( UDT::ERROR == UDT::bind( _udt, &address, sizeof( address ))) { LBERROR << UDTLASTERROR( "UDT::bind" ) << std::endl; - goto err; + return false; } + // get socket parameters + sockaddr_in inaddr; + int used = sizeof( inaddr ); + UDT::getsockname( _udt, (struct sockaddr *) &inaddr, &used ); + description->port = ntohs( inaddr.sin_port ); + if( UDT::ERROR == UDT::listen( _udt, SOMAXCONN )) { LBERROR << UDTLASTERROR( "UDT::listen" ) << std::endl; - goto err; + return false; } - if( initialize( )) - { - _setState( STATE_LISTENING ); - return true; - } -err: - return false; + if( !initialize( )) + return false; + + _setState( STATE_LISTENING ); + return true; } // caller: application @@ -521,7 +525,7 @@ int64_t UDTConnection::readSync( void* buffer, const uint64_t bytes, return 0LL; LBWARN << UDTLASTERROR( "UDT::recv" ) << std::endl; - close( ); + close(); return -1LL; } @@ -540,7 +544,6 @@ int64_t UDTConnection::readSync( void* buffer, const uint64_t bytes, { // Let the event thread continue polling lunchbox::ScopedMutex<> mutex( _app_mutex ); - _app_block.set( true ); } @@ -732,7 +735,7 @@ bool UDTConnection::UDTConnectionThread::init( ) } // caller: UDTConnectionThread -void UDTConnection::UDTConnectionThread::run( ) +void UDTConnection::UDTConnectionThread::run() { while( _running ) { diff --git a/tests/connection.cpp b/tests/connection.cpp index 2c4d9a9f0..dbcb4119f 100644 --- a/tests/connection.cpp +++ b/tests/connection.cpp @@ -1,5 +1,5 @@ -/* Copyright (c) 2010-2013, Stefan Eilemann +/* Copyright (c) 2010-2014, Stefan Eilemann * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 2.1 as published @@ -38,7 +38,7 @@ static co::ConnectionType types[] = co::CONNECTIONTYPE_NAMEDPIPE, co::CONNECTIONTYPE_RSP, co::CONNECTIONTYPE_RDMA, - co::CONNECTIONTYPE_UDT, +// co::CONNECTIONTYPE_UDT, co::CONNECTIONTYPE_NONE // must be last }; From 0b455109b0b3e4304f290758181832e18116b163 Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Tue, 21 Jan 2014 07:59:48 +0100 Subject: [PATCH 4/8] Fix #29: Change managers may access dangling objects --- co/object.cpp | 8 ++++---- co/objectCM.cpp | 5 +++++ co/objectCM.h | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/co/object.cpp b/co/object.cpp index 2f6646aef..b8459243e 100644 --- a/co/object.cpp +++ b/co/object.cpp @@ -181,11 +181,11 @@ void Object::_setChangeManager( ObjectCMPtr cm ) << lunchbox::className( cm ) << std::endl; } + impl_->cm->exit(); impl_->cm = cm; cm->init(); - LBLOG( LOG_OBJECTS ) << "set new change manager " << lunchbox::className( cm ) - << " for " << lunchbox::className( this ) - << std::endl; + LBLOG( LOG_OBJECTS ) << "set " << lunchbox::className( cm ) << " for " + << lunchbox::className( this ) << std::endl; } ObjectCMPtr Object::_getChangeManager() @@ -222,7 +222,7 @@ void Object::setupChangeManager( const Object::ChangeType type, switch( type ) { case Object::NONE: - LBASSERT( !impl_->localNode ); + LBASSERT( !localNode ); _setChangeManager( ObjectCM::ZERO ); break; diff --git a/co/objectCM.cpp b/co/objectCM.cpp index 2477f2bf4..9cd1a9bec 100644 --- a/co/objectCM.cpp +++ b/co/objectCM.cpp @@ -42,6 +42,11 @@ ObjectCM::ObjectCM( Object* object ) {} ObjectCM::~ObjectCM() +{ + LBASSERT( !_object ); +} + +void ObjectCM::exit() { lunchbox::ScopedFastWrite mutex( _lock ); _object = 0; diff --git a/co/objectCM.h b/co/objectCM.h index 86f3246cc..e53eeba64 100644 --- a/co/objectCM.h +++ b/co/objectCM.h @@ -56,6 +56,9 @@ class ObjectCM : public Dispatcher, public lunchbox::Referenced /** Initialize the change manager. */ virtual void init() = 0; + /** Deinitialize the change manager. */ + virtual void exit(); + /** @name Versioning */ //@{ /** @sa Object::push() */ From dc32cfd98525dfe7a87c000e183160fc02e4f871 Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Tue, 21 Jan 2014 08:07:45 +0100 Subject: [PATCH 5/8] CR 0af880eb0001e7b166984adfc9950b06667e78ed --- co/localNode.cpp | 7 +------ co/objectStore.cpp | 17 ++++++++++++++--- co/objectStore.h | 18 +++++++++++------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/co/localNode.cpp b/co/localNode.cpp index 4178560c5..db70aa018 100644 --- a/co/localNode.cpp +++ b/co/localNode.cpp @@ -698,12 +698,7 @@ bool LocalNode::mapObjectSync( const uint32_t requestID ) f_bool_t LocalNode::syncObject( Object* object, NodePtr master, const UUID& id, const uint32_t instanceID ) { - const uint32_t request = _impl->objectStore->syncNB( object, master, id, - instanceID ); - const FuturebImpl::Func& func = boost::bind( &ObjectStore::syncSync, - _impl->objectStore, request, - object ); - return f_bool_t( new FuturebImpl( func )); + return _impl->objectStore->sync( object, master, id, instanceID ); } void LocalNode::unmapObject( Object* object ) diff --git a/co/objectStore.cpp b/co/objectStore.cpp index 559b44269..efadac221 100644 --- a/co/objectStore.cpp +++ b/co/objectStore.cpp @@ -46,6 +46,7 @@ namespace co { typedef CommandFunc< ObjectStore > CmdFunc; +typedef lunchbox::FutureFunction< bool > FuturebImpl; ObjectStore::ObjectStore( LocalNode* localNode, a_ssize_t* counters ) : _localNode( localNode ) @@ -441,8 +442,18 @@ bool ObjectStore::mapSync( const uint32_t requestID ) return mapped; } -uint32_t ObjectStore::syncNB( Object* object, NodePtr master, const UUID& id, - const uint32_t instanceID ) + +f_bool_t ObjectStore::sync( Object* object, NodePtr master, const UUID& id, + const uint32_t instanceID ) +{ + const uint32_t request = _startSync( object, master, id, instanceID ); + const FuturebImpl::Func& func = boost::bind( &ObjectStore::_finishSync, + this, request, object ); + return f_bool_t( new FuturebImpl( func )); +} + +uint32_t ObjectStore::_startSync( Object* object, NodePtr master, + const UUID& id, const uint32_t instanceID ) { LB_TS_NOT_THREAD( _receiverThread ); LBLOG( LOG_OBJECTS ) @@ -499,7 +510,7 @@ uint32_t ObjectStore::syncNB( Object* object, NodePtr master, const UUID& id, return requestID; } -bool ObjectStore::syncSync( const uint32_t requestID, Object* object ) +bool ObjectStore::_finishSync( const uint32_t requestID, Object* object ) { if( requestID == LB_UNDEFINED_UINT32 ) return false; diff --git a/co/objectStore.h b/co/objectStore.h index f411c2659..00004c2ba 100644 --- a/co/objectStore.h +++ b/co/objectStore.h @@ -101,13 +101,9 @@ class ObjectStore : public Dispatcher /** Finalize the mapping of a distributed object. */ bool mapSync( const uint32_t requestID ); - /** Start synchronizing an object. */ - uint32_t syncNB( Object* object, NodePtr master, const UUID& id, - const uint32_t instanceID ); - - /** Finalize the synchronizatin of a distributed object. */ - bool syncSync( const uint32_t requestID, Object* object ); - + /** Synchronize an object. */ + f_bool_t sync( Object* object, NodePtr master, const UUID& id, + const uint32_t instanceID ); /** * Unmap a mapped object. * @@ -215,6 +211,14 @@ class ObjectStore : public Dispatcher void _attach( Object* object, const UUID& id, const uint32_t instanceID ); void _detach( Object* object ); + + /** Start synchronizing an object. */ + uint32_t _startSync( Object* object, NodePtr master, const UUID& id, + const uint32_t instanceID ); + + /** Finalize the synchronizatin of a distributed object. */ + bool _finishSync( const uint32_t requestID, Object* object ); + bool _checkInstanceCache( const UUID& id, uint128_t& from, uint128_t& to, uint32_t& instanceID ); From 735f22ef50e84a9a958fa513ab55b4b8574344a9 Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Tue, 21 Jan 2014 11:42:42 +0100 Subject: [PATCH 6/8] CR #75 --- co/objectCM.h | 3 ++- co/staticMasterCM.h | 2 +- co/versionedMasterCM.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/co/objectCM.h b/co/objectCM.h index e53eeba64..eb19eb0a9 100644 --- a/co/objectCM.h +++ b/co/objectCM.h @@ -69,7 +69,7 @@ class ObjectCM : public Dispatcher, public lunchbox::Referenced * Synchronize an instance to the managed object. * * @param command the command initiating the sync. - * @return true on success, false otherwise. + * @return true if handled, false otherwise. */ virtual bool sendSync( const MasterCMCommand& command ); @@ -130,6 +130,7 @@ class ObjectCM : public Dispatcher, public lunchbox::Referenced * Add a subscribed slave to the managed object. * * @param command the subscribe command initiating the add. + * @return true if handled, false otherwise. */ virtual bool addSlave( const MasterCMCommand& command ) = 0; diff --git a/co/staticMasterCM.h b/co/staticMasterCM.h index af662ace8..ccabd23d5 100644 --- a/co/staticMasterCM.h +++ b/co/staticMasterCM.h @@ -57,7 +57,7 @@ namespace co { LBDONTCALL; return CO_INSTANCE_INVALID; } bool addSlave( const MasterCMCommand& command ) override - { return _addSlave( command, VERSION_FIRST ); } + { return ObjectCM::_addSlave( command, VERSION_FIRST ); } void removeSlaves( NodePtr ) override { /* NOP */} }; } diff --git a/co/versionedMasterCM.cpp b/co/versionedMasterCM.cpp index 26ef7702a..bc61c3704 100644 --- a/co/versionedMasterCM.cpp +++ b/co/versionedMasterCM.cpp @@ -106,7 +106,7 @@ bool VersionedMasterCM::addSlave( const MasterCMCommand& command ) LB_TS_THREAD( _cmdThread ); Mutex mutex( _slaves ); - if( !_addSlave( command, _version )) + if( !ObjectCM::_addSlave( command, _version )) return false; SlaveData data; From 4fecdd26c27d8619b8556e5fc8abefe47ae8d6c3 Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Tue, 21 Jan 2014 11:46:26 +0100 Subject: [PATCH 7/8] Typo --- co/objectStore.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/co/objectStore.h b/co/objectStore.h index 00004c2ba..03dbb2a18 100644 --- a/co/objectStore.h +++ b/co/objectStore.h @@ -216,7 +216,7 @@ class ObjectStore : public Dispatcher uint32_t _startSync( Object* object, NodePtr master, const UUID& id, const uint32_t instanceID ); - /** Finalize the synchronizatin of a distributed object. */ + /** Finalize the synchronization of a distributed object. */ bool _finishSync( const uint32_t requestID, Object* object ); bool _checkInstanceCache( const UUID& id, uint128_t& from, From c13cc3d489270e92a17487f1b030b3e04ff5364f Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Tue, 21 Jan 2014 11:54:55 +0100 Subject: [PATCH 8/8] Fix unit tests --- co/object.cpp | 4 ++-- co/objectCM.cpp | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/co/object.cpp b/co/object.cpp index b8459243e..818f376af 100644 --- a/co/object.cpp +++ b/co/object.cpp @@ -1,5 +1,5 @@ -/* Copyright (c) 2005-2013, Stefan Eilemann +/* Copyright (c) 2005-2014, Stefan Eilemann * 2011-2012, Daniel Nachbaur * * This file is part of Collage @@ -85,8 +85,8 @@ Object::~Object() if( impl_->localNode ) impl_->localNode->releaseObject( this ); - impl_->localNode = 0; + impl_->localNode = 0; impl_->cm = 0; delete impl_; } diff --git a/co/objectCM.cpp b/co/objectCM.cpp index 9cd1a9bec..37223b26c 100644 --- a/co/objectCM.cpp +++ b/co/objectCM.cpp @@ -1,5 +1,5 @@ -/* Copyright (c) 2007-2013, Stefan Eilemann +/* Copyright (c) 2007-2014, Stefan Eilemann * 2011-2012, Daniel Nachbaur * * This file is part of Collage @@ -42,9 +42,7 @@ ObjectCM::ObjectCM( Object* object ) {} ObjectCM::~ObjectCM() -{ - LBASSERT( !_object ); -} +{} void ObjectCM::exit() {