Revision: 8225 http://playerstage.svn.sourceforge.net/playerstage/?rev=8225&view=rev Author: hsujohnhsu Date: 2009-08-26 06:08:55 +0000 (Wed, 26 Aug 2009)
Log Message: ----------- fix race condition errors: * call msync() for opening mmap, seems to need it mostly running on slow file systems such as nfs. * remove toAddModels, add to models queue directly at spawn time. simplify code: * removed ProcessMessages() and call UpdateSimulationIface() directly. Modified Paths: -------------- code/gazebo/trunk/libgazebo/Iface.cc code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/World.cc code/gazebo/trunk/server/World.hh Modified: code/gazebo/trunk/libgazebo/Iface.cc =================================================================== --- code/gazebo/trunk/libgazebo/Iface.cc 2009-08-25 18:58:06 UTC (rev 8224) +++ code/gazebo/trunk/libgazebo/Iface.cc 2009-08-26 06:08:55 UTC (rev 8225) @@ -288,6 +288,12 @@ // Map the mmap file this->mMap = mmap(0, this->size, PROT_READ | PROT_WRITE, MAP_SHARED, this->mmapFd, 0); + // flushes changes made to the in-core copy of a mmap file + if (msync( this->mMap, this->size, MS_SYNC)) + { + stream << "error msync mmap: " << strerror(errno); + throw(stream.str()); + } if (this->mMap == MAP_FAILED) { Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2009-08-25 18:58:06 UTC (rev 8224) +++ code/gazebo/trunk/server/Simulator.cc 2009-08-26 06:08:55 UTC (rev 8225) @@ -676,7 +676,7 @@ nanosleep(&req, &rem); // Process all incoming messages from simiface - world->ProcessMessages(); + world->UpdateSimulationIface(); if (this->timeout > 0 && this->GetRealTime() > this->timeout) { Modified: code/gazebo/trunk/server/World.cc =================================================================== --- code/gazebo/trunk/server/World.cc 2009-08-25 18:58:06 UTC (rev 8224) +++ code/gazebo/trunk/server/World.cc 2009-08-26 06:08:55 UTC (rev 8225) @@ -218,7 +218,6 @@ if (this->openAL) this->openAL->Init(); - this->toAddModels.clear(); this->toDeleteModels.clear(); this->toLoadEntities.clear(); @@ -304,13 +303,6 @@ } //////////////////////////////////////////////////////////////////////////////// -// Process messages -void World::ProcessMessages() -{ - this->UpdateSimulationIface(); -} - -//////////////////////////////////////////////////////////////////////////////// // Finilize the world void World::Fini() { @@ -477,13 +469,10 @@ this->SetModelPose(model, model->GetInitPose()); // Add the model to our list - if (Simulator::Instance()->GetSimTime() == 0) - this->models.push_back(model); - else - { + this->models.push_back(model); + + if (Simulator::Instance()->GetSimTime() > 0) model->Init(); - this->toAddModels.push_back(model); - } if (parent != NULL) model->Attach(node->GetChild("attach")); @@ -1257,16 +1246,8 @@ this->simIface->Unlock(); - - std::vector< Model* >::iterator miter; - - // Copy the newly created models into the main model vector - std::copy(this->toAddModels.begin(), this->toAddModels.end(), - std::back_inserter(this->models)); - this->toAddModels.clear(); - - // Remove and delete all models that are marked for deletion + std::vector< Model* >::iterator miter; for (miter=this->toDeleteModels.begin(); miter!=this->toDeleteModels.end(); miter++) { Modified: code/gazebo/trunk/server/World.hh =================================================================== --- code/gazebo/trunk/server/World.hh 2009-08-25 18:58:06 UTC (rev 8224) +++ code/gazebo/trunk/server/World.hh 2009-08-26 06:08:55 UTC (rev 8225) @@ -176,8 +176,6 @@ /// \brief Get whether to view as wireframe public: bool GetShowPhysics(); - public: void ProcessMessages(); - /// Set to true to show bounding boxes private: bool showBoundingBoxes; @@ -202,7 +200,7 @@ private: void SetModelPose(Model *model , Pose3d pose); /// \brief Update the simulation iface - private: void UpdateSimulationIface(); + public: void UpdateSimulationIface(); /// \brif Get the names of interfaces defined in the tree of a model private: void GetInterfaceNames(Entity* m, std::vector<std::string>& list); @@ -216,9 +214,6 @@ /// List of all the registered geometries private: std::vector< Geom* > geometries; - /// List of models to add into the world - private: std::vector< Model* > toAddModels; - /// List of models to delete from the world private: std::vector< Model* > toDeleteModels; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit