Revision: 6672
          http://playerstage.svn.sourceforge.net/playerstage/?rev=6672&view=rev
Author:   thjc
Date:     2008-06-23 21:59:00 -0700 (Mon, 23 Jun 2008)

Log Message:
-----------
added so extra tests to prevent deadlocks in drivers that make player requests 
in their shutdown methods. These could deadlock while the server was shutting 
down.

Modified Paths:
--------------
    code/player/branches/release-2-1-patches/libplayercore/device.cc
    code/player/branches/release-2-1-patches/libplayercore/devicetable.cc

Modified: code/player/branches/release-2-1-patches/libplayercore/device.cc
===================================================================
--- code/player/branches/release-2-1-patches/libplayercore/device.cc    
2008-06-24 00:31:46 UTC (rev 6671)
+++ code/player/branches/release-2-1-patches/libplayercore/device.cc    
2008-06-24 04:59:00 UTC (rev 6672)
@@ -258,6 +258,9 @@
                 double* timestamp,
                 bool threaded)
 {
+  // check driver still ahs subscriptions, stops deadlocks on server shutdown
+  if (driver->subscriptions == 0)
+    return NULL;
   // Send the request message
   this->PutMsg(resp_queue,
                type, subtype,
@@ -282,13 +285,13 @@
   // non-threaded, then his ProcessMessage() would get called
   // recursively).
 
-  Message* msg;
+  Message* msg = NULL;
   if(threaded)
   {
-    resp_queue->Wait();
     // HACK: this loop should not be neccesary!
     // pthread_cond_wait does not garuntee no false wake up, so maybe it is.
-    while(!(msg = resp_queue->Pop()))
+    // test driver is still subscribed to prevent deadlocks on server shutdown
+    while(driver->subscriptions > 0 && !(msg = resp_queue->Pop()))
     {
       PLAYER_WARN("empty queue after waiting!");
       resp_queue->Wait(); // this is a cancelation point

Modified: code/player/branches/release-2-1-patches/libplayercore/devicetable.cc
===================================================================
--- code/player/branches/release-2-1-patches/libplayercore/devicetable.cc       
2008-06-24 00:31:46 UTC (rev 6671)
+++ code/player/branches/release-2-1-patches/libplayercore/devicetable.cc       
2008-06-24 04:59:00 UTC (rev 6672)
@@ -74,6 +74,8 @@
       thisentry->driver->Shutdown();
       thisentry->driver->subscriptions = 0;
       thisentry->driver->alwayson = 0;
+      // wake up anything waiting on the drivers queue, so they can notice it 
is dead
+      thisentry->driver->InQueue->DataAvailable();
     }
     thisentry = thisentry->next;
   }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to