[stage/f13/master] - Fix multiple subscription/unsubscription crashes - Allow stageplugin to be run without gui

rmattes rmattes at fedoraproject.org
Mon Jan 24 01:18:16 UTC 2011


commit 87e932b746e3cc1fb8db7c31edcd53b5751cd73b
Author: Rich <richmattes at gmail.com>
Date:   Sun Jan 23 20:09:35 2011 -0500

    - Fix multiple subscription/unsubscription crashes
    - Allow stageplugin to be run without gui

 stage-3.2.2.fixconsumequeue.patch |   38 ++++++++++++++++
 stage-3.2.2.fixunsubscribe.patch  |   86 +++++++++++++++++++++++++++++++++++++
 stage-3.2.2.playernogui.patch     |   63 +++++++++++++++++++++++++++
 stage.spec                        |   16 ++++++-
 4 files changed, 201 insertions(+), 2 deletions(-)
---
diff --git a/stage-3.2.2.fixconsumequeue.patch b/stage-3.2.2.fixconsumequeue.patch
new file mode 100644
index 0000000..a0af061
--- /dev/null
+++ b/stage-3.2.2.fixconsumequeue.patch
@@ -0,0 +1,38 @@
+Index: libstage/world.cc
+===================================================================
+--- libstage/world.cc	(revision 1980)
++++ libstage/world.cc	(working copy)
+@@ -520,20 +520,22 @@
+     return;
+   
+   //printf( "event queue len %d\n", (int)queue.size() );
+-
++  
+   // update everything on the event queue that happens at this time or earlier
+-  Event ev( queue.top() );    
+-  while(  ev.time <= sim_time ) 
++  do
+     {
+-      // printf( "@ %llu next event <%s %llu %s>\n",  sim_time, ev.TypeStr( ev.type ), ev.time, ev.mod->Token() ); 
+-      queue.pop();      
+-		
+-		if( ev.mod->subs > 0 ) // no subscriptions means the event is discarded
+-		  ev.mod->Update(); // update the model
+-
+-      // and move to the next
+-      ev = queue.top();
++      Event ev( queue.top() );
++      if( ev.time > sim_time ) break;
++      queue.pop();
++      
++      //printf( "@ %llu next event ptr %p\n", sim_time, ev.mod );
++      //std::string modelType = ev.mod->GetModelType();
++      //printf( "@ %llu next event <%s %llu %s>\n",  sim_time, modelType.c_str(), ev.time, ev.mod->Token() ); 
++      
++      if( ev.mod->subs > 0 ) // no subscriptions means the event is discarded
++        ev.mod->Update(); // update the model
+     }
++  while( !queue.empty() );
+ }
+ 
+ 
diff --git a/stage-3.2.2.fixunsubscribe.patch b/stage-3.2.2.fixunsubscribe.patch
new file mode 100644
index 0000000..af9035d
--- /dev/null
+++ b/stage-3.2.2.fixunsubscribe.patch
@@ -0,0 +1,86 @@
+Index: libstage/model.cc
+===================================================================
+--- libstage/model.cc	(revision 1980)
++++ libstage/model.cc	(working copy)
+@@ -640,7 +640,7 @@
+   world->total_subs++;
+   world->dirty = true; // need redraw
+   
+-  //printf( "subscribe to %s %d\n", token, subs );
++  //printf( "subscribe to %s %d\n", Token(), subs );
+   
+   // if this is the first sub, call startup
+   if( subs == 1 )
+@@ -653,7 +653,7 @@
+   world->total_subs--;
+   world->dirty = true; // need redraw
+ 
+-  //printf( "unsubscribe from %s %d\n", token, subs );
++  //printf( "unsubscribe from %s %d\n", Token(), subs );
+ 
+   // if this is the last sub, call shutdown
+   if( subs == 0 )
+Index: libstageplugin/p_driver.cc
+===================================================================
+--- libstageplugin/p_driver.cc	(revision 1980)
++++ libstageplugin/p_driver.cc	(working copy)
+@@ -228,7 +228,7 @@
+ 											ConfigFile* cf,
+ 											int section,
+ 											const std::string& type )
+-  : Interface( addr, driver, cf, section )
++  : Interface( addr, driver, cf, section ), mod( NULL ), subscribed( false )
+ {
+   char* model_name = (char*)cf->ReadString(section, "model", NULL );
+ 
+@@ -260,7 +260,25 @@
+     printf( "\"%s\"\n", this->mod->Token() );
+ }
+ 
++void InterfaceModel::Subscribe()
++{
++  if( !subscribed && this->mod )
++    {
++      this->mod->Subscribe();
++      subscribed = true;
++    }
++}
+ 
++void InterfaceModel::Unsubscribe()
++{
++  if( subscribed )
++    {
++      this->mod->Unsubscribe();
++      subscribed = false;
++    }
++}
++
++
+ // Constructor.  Retrieve options from the configuration file and do any
+ // pre-Setup() setup.
+ 
+Index: libstageplugin/p_driver.h
+===================================================================
+--- libstageplugin/p_driver.h	(revision 1980)
++++ libstageplugin/p_driver.h	(working copy)
+@@ -104,12 +104,16 @@
+ 		  int section,
+ 		  const std::string& type );
+ 
++  virtual ~InterfaceModel( void ){ Unsubscribe(); };
++
++  virtual void Subscribe( void );
++  virtual void Unsubscribe( void );
++
++ protected:
+   Stg::Model* mod;
+ 
+-  virtual ~InterfaceModel( void ){ /* TODO: clean up*/ };
+-
+-  virtual void Subscribe( void ){ this->mod->Subscribe(); };
+-  virtual void Unsubscribe( void ){ this->mod->Unsubscribe(); };
++ private:
++  bool subscribed;
+ };
+ 
+ 
diff --git a/stage-3.2.2.playernogui.patch b/stage-3.2.2.playernogui.patch
new file mode 100644
index 0000000..37d1349
--- /dev/null
+++ b/stage-3.2.2.playernogui.patch
@@ -0,0 +1,63 @@
+Index: libstageplugin/p_simulation.cc
+===================================================================
+--- libstageplugin/p_simulation.cc	(revision 8564)
++++ libstageplugin/p_simulation.cc	(working copy)
+@@ -78,6 +78,7 @@
+   Stg::Init( &player_argc, &player_argv );
+ 
+   const char* worldfile_name = cf->ReadString(section, "worldfile", NULL );
++  StgDriver::usegui = cf->ReadBool(section, "usegui", 1 );
+ 
+   if( worldfile_name == NULL )
+     {
+@@ -113,7 +114,7 @@
+   // worldfile
+ 
+   // if the initial size is to large this crashes on some systems
+-  StgDriver::world = new WorldGui( 400, 300, "Player/Stage" );
++  StgDriver::world = ( StgDriver::usegui ? new WorldGui( 400, 300, worldfile_name ) : new World(worldfile_name));
+   assert(StgDriver::world);
+ 
+   puts("");
+Index: libstageplugin/p_driver.cc
+===================================================================
+--- libstageplugin/p_driver.cc	(revision 8564)
++++ libstageplugin/p_driver.cc	(working copy)
+@@ -167,7 +167,8 @@
+ extern bool player_quit;
+ 
+ // init static vars
+-WorldGui* StgDriver::world = NULL;
++World* StgDriver::world = NULL;
++bool StgDriver::usegui = true;
+ 
+ //int update_request = 0;
+ 
+@@ -577,8 +578,11 @@
+ 			switch( interface->addr.interf )
+ 				{
+ 				case PLAYER_SIMULATION_CODE:
+-				  // one round of FLTK's update loop.
+-				  Fl::wait();
++					// one round of FLTK's update loop.
++					if (StgDriver::usegui)
++						Fl::wait();
++					else
++						StgDriver::world->Update();
+ 					break;
+ 					
+ 				default:
+Index: libstageplugin/p_driver.h
+===================================================================
+--- libstageplugin/p_driver.h	(revision 8564)
++++ libstageplugin/p_driver.h	(working copy)
+@@ -38,7 +38,8 @@
+   virtual void Update();
+ 
+   /// all player devices share the same Stage world (for now)
+-  static Stg::WorldGui* world;
++  static Stg::World* world;
++  static bool usegui;
+ 
+   /// find the device record with this Player id
+   Interface* LookupDevice( player_devaddr_t addr );
diff --git a/stage.spec b/stage.spec
index 5240ca6..d0e305c 100644
--- a/stage.spec
+++ b/stage.spec
@@ -1,6 +1,6 @@
 Name:           stage
 Version:        3.2.2
-Release:        7%{?dist}
+Release:        8%{?dist}
 Summary:        A 2.5D multi-robot simulator
 
 Group:          Applications/Engineering
@@ -14,8 +14,13 @@ Patch0:         stage-3.2.2.fixcmake64.patch
 Patch1:         stage-3.2.2.fixlibload.patch
 # Fixes installation of example worlds, submitted at https://sourceforge.net/tracker/?func=detail&aid=2871625&group_id=42445&atid=433166
 Patch2:         stage-3.2.2.fixexamples.patch
-# Fixes DSO linking problem for executable.  Not yet submitted upstream.
+# Fixes DSO linking problem for executable.
 Patch3:         stage-3.2.2.fixdso.patch
+# Fixes for consumequeue and client unsubscription, accepted upstream
+Patch4:         stage-3.2.2.fixconsumequeue.patch
+Patch5:         stage-3.2.2.fixunsubscribe.patch
+Patch6:         stage-3.2.2.playernogui.patch
+
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  cmake
@@ -69,6 +74,9 @@ and manipulated through the Player server.
 %patch1 -p1 
 %patch2 -p1 
 %patch3 -p1 
+%patch4 -p0
+%patch5 -p0
+%patch6 -p0
 
 
 %build
@@ -123,6 +131,10 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Sun Jan 23 2011 Rich Mattes <richmattes at gmail.com> - 3.2.2-8
+- Fix multiple subscription/unsubscription crashes
+- Allow stageplugin to be run without gui
+
 * Sun Mar 14 2010 Rich Mattes <richmattes at gmail.com> - 3.2.2-7
 - Merged -doc subpackage into -devel
 - Added Requires pkgconfig entries


More information about the scm-commits mailing list