summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2005-07-17 23:05:09 +0000
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2005-07-17 23:05:09 +0000
commit527031e1d79b23f668049d08738200de45221daa (patch)
tree6c5dadfa7438146cd7d602b170bb35143209214b
parent9b5bc8acf999d994f0eb5cfa4671c55ac63040de (diff)
downloadxine-lib-527031e1d79b23f668049d08738200de45221daa.tar.gz
xine-lib-527031e1d79b23f668049d08738200de45221daa.tar.bz2
**BUGFIX**
Locking problem with string config item callbacks which access config items. CVS patchset: 7655 CVS date: 2005/07/17 23:05:09
-rw-r--r--src/xine-engine/configfile.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c
index c58c04216..a663fa815 100644
--- a/src/xine-engine/configfile.c
+++ b/src/xine-engine/configfile.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: configfile.c,v 1.76 2005/02/07 18:53:17 tmattern Exp $
+ * $Id: configfile.c,v 1.77 2005/07/17 23:05:09 dsalt Exp $
*
* config object (was: file) management - implementation
*
@@ -814,6 +814,7 @@ static void config_update_string (config_values_t *this,
cfg_entry_t *entry;
char *str_free = NULL;
+ static pthread_mutex_t update_lock = PTHREAD_MUTEX_INITIALIZER;
lprintf ("updating %s to %s\n", key, value);
@@ -840,6 +841,7 @@ static void config_update_string (config_values_t *this,
return;
}
+ pthread_mutex_lock (&update_lock);
pthread_mutex_lock(&this->config_lock);
if (value != entry->str_value) {
str_free = entry->str_value;
@@ -850,14 +852,17 @@ static void config_update_string (config_values_t *this,
xine_cfg_entry_t cb_entry;
config_shallow_copy(&cb_entry, entry);
- /* FIXME: find a solution which does not enter the callback with the lock acquired,
- * but does also handle the char* leak- and race-free without unnecessary string copying */
+ free (str_free);
+ pthread_mutex_unlock (&this->config_lock);
+
entry->callback (entry->callback_data, &cb_entry);
}
-
- if (str_free)
+ else
+ {
free(str_free);
- pthread_mutex_unlock(&this->config_lock);
+ pthread_mutex_unlock(&this->config_lock);
+ }
+ pthread_mutex_unlock (&update_lock);
}
/*