Xine-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Original]

[xine-devel] [PATCH] Make catalog mutex recursive (was:_x_load_video_out


To: xine-devel@xxxxxxxxxxxxxxxxxxxxx
Subject: [xine-devel] [PATCH] Make catalog mutex recursive (was:_x_load_video_output_plugin recursion)
From: Jason Tackaberry <tack@xxxxxxxxx>
Date: Fri, 25 Nov 2005 08:59:12 -0500
Delivered-to: itdp@localhost
In-reply-to: <1132682065.24790.41.camel@draco.sault.org>
References: <1132682065.24790.41.camel@draco.sault.org>

On Tue, 2005-11-22 at 12:54 -0500, Jason Tackaberry wrote:
> deadlock, because this function doesn't allow recursion.  (The function
> first acquires a lock on catalog->lock, and reentry will of course
> deadlock.)

The attached patch makes the catalog mutex recursive, which fixes my
problem and allows the driver's open_plugin to call
_x_load_video_output_plugin().  Neither pthread_cond_wait nor
pthread_cond_timedwait are used on this mutex, and some cursory testing
hasn't shown any negative side effects.

Still, threads are insidious, so review definitely required. :)  If
there are no objections, I can commit it.

Cheers,
Jason.
--- xine-lib.orig/src/xine-engine/load_plugins.c        2005-09-19 
12:14:02.000000000 -0400
+++ xine-lib/src/xine-engine/load_plugins.c     2005-11-25 08:41:29.000000000 
-0500
@@ -437,6 +437,7 @@
 static plugin_catalog_t *_new_catalog(void){
 
   plugin_catalog_t *catalog;
+  pthread_mutexattr_t attr;
   int i;
 
   catalog = xine_xmalloc(sizeof(plugin_catalog_t));
@@ -447,7 +448,9 @@
 
   catalog->cache_list = xine_list_new();
   catalog->file_list  = xine_list_new();
-  pthread_mutex_init (&catalog->lock, NULL);
+  pthread_mutexattr_init (&attr);
+  pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
+  pthread_mutex_init (&catalog->lock, &attr);
 
   return catalog;
 }

Attachment: signature.asc
Description: This is a digitally signed message part


[Prev in Thread] Current Thread [Next in Thread]