Revision: 6908
          http://playerstage.svn.sourceforge.net/playerstage/?rev=6908&view=rev
Author:   thjc
Date:     2008-07-23 06:01:19 +0000 (Wed, 23 Jul 2008)

Log Message:
-----------
Merged 6672 from 2-1
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/trunk/libplayercore/device.cc
    code/player/trunk/libplayercore/devicetable.cc

Property Changed:
----------------
    code/player/trunk/


Property changes on: code/player/trunk
___________________________________________________________________
Added: svn:mergeinfo
   + /code/player/branches/release-2-1-patches:6672

Modified: code/player/trunk/libplayercore/device.cc
===================================================================
--- code/player/trunk/libplayercore/device.cc   2008-07-23 05:30:31 UTC (rev 
6907)
+++ code/player/trunk/libplayercore/device.cc   2008-07-23 06:01:19 UTC (rev 
6908)
@@ -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/trunk/libplayercore/devicetable.cc
===================================================================
--- code/player/trunk/libplayercore/devicetable.cc      2008-07-23 05:30:31 UTC 
(rev 6907)
+++ code/player/trunk/libplayercore/devicetable.cc      2008-07-23 06:01:19 UTC 
(rev 6908)
@@ -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.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to