Browse Source

prevent self-deadlock

David Rose 19 years ago
parent
commit
0f20f625f3

+ 1 - 1
panda/src/display/graphicsEngine.cxx

@@ -1593,7 +1593,7 @@ do_add_gsg(GraphicsStateGuardian *gsg, GraphicsPipe *pipe,
            const GraphicsThreadingModel &threading_model) {
   MutexHolder holder(_lock);
 
-  gsg->_threading_model = get_threading_model();
+  gsg->_threading_model = threading_model;
   gsg->_pipe = pipe;
   gsg->_engine = this;
 

+ 1 - 2
panda/src/glxdisplay/glxGraphicsPipe.cxx

@@ -22,7 +22,6 @@
 #include "glxGraphicsStateGuardian.h"
 #include "config_glxdisplay.h"
 #include "frameBufferProperties.h"
-#include "mutexHolder.h"
 
 TypeHandle glxGraphicsPipe::_type_handle;
 
@@ -30,7 +29,7 @@ bool glxGraphicsPipe::_error_handlers_installed = false;
 glxGraphicsPipe::ErrorHandlerFunc *glxGraphicsPipe::_prev_error_handler;
 glxGraphicsPipe::IOErrorHandlerFunc *glxGraphicsPipe::_prev_io_error_handler;
 
-Mutex glxGraphicsPipe::_x_mutex;
+ReMutex glxGraphicsPipe::_x_mutex;
 
 ////////////////////////////////////////////////////////////////////
 //     Function: glxGraphicsPipe::Constructor

+ 2 - 1
panda/src/glxdisplay/glxGraphicsPipe.h

@@ -24,6 +24,7 @@
 #include "graphicsPipe.h"
 #include "glgsg.h"
 #include "pmutex.h"
+#include "reMutex.h"
 
 class FrameBufferProperties;
 
@@ -144,7 +145,7 @@ private:
 public:
   // This Mutex protects any X library calls, which all have to be
   // single-threaded.  In particular, it protects glXMakeCurrent().
-  static Mutex _x_mutex;
+  static ReMutex _x_mutex;
 
 public:
   static TypeHandle get_class_type() {

+ 3 - 2
panda/src/glxdisplay/glxGraphicsStateGuardian.cxx

@@ -19,6 +19,7 @@
 #include "glxGraphicsStateGuardian.h"
 #include "config_glxdisplay.h"
 #include "config_glgsg.h"
+#include "reMutexHolder.h"
 
 #include <dlfcn.h>
 
@@ -391,7 +392,7 @@ glx_is_at_least_version(int major_version, int minor_version) const {
 void glxGraphicsStateGuardian::
 gl_flush() const {
   // This call requires synchronization with X.
-  MutexHolder holder(glxGraphicsPipe::_x_mutex);
+  ReMutexHolder holder(glxGraphicsPipe::_x_mutex);
   GLGraphicsStateGuardian::gl_flush();
 }
 
@@ -403,7 +404,7 @@ gl_flush() const {
 GLenum glxGraphicsStateGuardian::
 gl_get_error() const {
   // This call requires synchronization with X.
-  MutexHolder holder(glxGraphicsPipe::_x_mutex);
+  ReMutexHolder holder(glxGraphicsPipe::_x_mutex);
   return GLGraphicsStateGuardian::gl_get_error();
 }
 

+ 4 - 3
panda/src/glxdisplay/glxGraphicsWindow.cxx

@@ -29,6 +29,7 @@
 #include "pStatTimer.h"
 #include "textEncoder.h"
 #include "throw_event.h"
+#include "reMutexHolder.h"
 
 #include <errno.h>
 #include <sys/time.h>
@@ -132,7 +133,7 @@ begin_frame(FrameMode mode, Thread *current_thread) {
   glxGraphicsStateGuardian *glxgsg;
   DCAST_INTO_R(glxgsg, _gsg, false);
   {
-    MutexHolder holder(glxGraphicsPipe::_x_mutex);
+    ReMutexHolder holder(glxGraphicsPipe::_x_mutex);
     glXMakeCurrent(_display, _xwindow, glxgsg->_context);
   }
   
@@ -203,7 +204,7 @@ begin_flip() {
 
     //make_current();
 
-    MutexHolder holder(glxGraphicsPipe::_x_mutex);
+    ReMutexHolder holder(glxGraphicsPipe::_x_mutex);
     glXSwapBuffers(_display, _xwindow);
   }
 }
@@ -220,7 +221,7 @@ begin_flip() {
 ////////////////////////////////////////////////////////////////////
 void glxGraphicsWindow::
 process_events() {
-  MutexHolder holder(glxGraphicsPipe::_x_mutex);
+  ReMutexHolder holder(glxGraphicsPipe::_x_mutex);
 
   GraphicsWindow::process_events();