diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2006-07-21 10:40:25 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2006-07-21 10:40:25 +0000 |
commit | c345ebb06a602d884bd2a1c0c675e50e5f57cba3 (patch) | |
tree | 3ea3aeccc5ed246b648ea8eaa996d8e2bf9971c3 /gst/gstparse.c | |
parent | 626d7a1fb211ff309be0f53f297620d46e8663f8 (diff) |
gst/gstparse.c: Protect recursive calls to _parse with a recursive mutex and busy flag.
Original commit message from CVS:
* gst/gstparse.c: (gst_parse_launch):
Protect recursive calls to _parse with a recursive mutex
and busy flag.
Diffstat (limited to 'gst/gstparse.c')
-rw-r--r-- | gst/gstparse.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/gst/gstparse.c b/gst/gstparse.c index 7847952f6..f966b5156 100644 --- a/gst/gstparse.c +++ b/gst/gstparse.c @@ -36,6 +36,10 @@ #include "gstparse.h" #include "gstinfo.h" +/* the need for the mutex will go away with flex 2.5.6 */ +static gboolean flex_busy = FALSE; +static GStaticRecMutex flex_lock = G_STATIC_REC_MUTEX_INIT; + extern GstElement *_gst_parse_launch (const gchar *, GError **); /** @@ -136,21 +140,31 @@ gst_parse_launchv (const gchar ** argv, GError ** error) GstElement * gst_parse_launch (const gchar * pipeline_description, GError ** error) { - GstElement *element = NULL; - static GStaticMutex flex_lock = G_STATIC_MUTEX_INIT; + GstElement *element; g_return_val_if_fail (pipeline_description != NULL, NULL); GST_CAT_INFO (GST_CAT_PIPELINE, "parsing pipeline description %s", pipeline_description); - /* the need for the mutex will go away with flex 2.5.6 */ - if (g_static_mutex_trylock (&flex_lock)) { - element = _gst_parse_launch (pipeline_description, error); - g_static_mutex_unlock (&flex_lock); - } else { - GST_WARNING ("gst_parse_launch() cannot be nested"); - } + g_static_rec_mutex_lock (&flex_lock); + if (flex_busy) + goto recursive_call; + flex_busy = TRUE; + + element = _gst_parse_launch (pipeline_description, error); + + flex_busy = FALSE; + g_static_rec_mutex_unlock (&flex_lock); return element; + + /* ERRORS */ +recursive_call: + { + GST_WARNING ("calls to gst_parse_launch() cannot be nested"); + g_static_rec_mutex_unlock (&flex_lock); + g_warning ("calls to gst_parse_launch() cannot be nested"); + return NULL; + } } |