mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:36:20 +00:00
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.
This commit is contained in:
parent
626d7a1fb2
commit
c345ebb06a
2 changed files with 29 additions and 9 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2006-07-21 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/gstparse.c: (gst_parse_launch):
|
||||||
|
Protect recursive calls to _parse with a recursive mutex
|
||||||
|
and busy flag.
|
||||||
|
|
||||||
2006-07-21 Wim Taymans <wim@fluendo.com>
|
2006-07-21 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* tests/check/gst/gstpad.c: (GST_START_TEST):
|
* tests/check/gst/gstpad.c: (GST_START_TEST):
|
||||||
|
|
|
@ -36,6 +36,10 @@
|
||||||
#include "gstparse.h"
|
#include "gstparse.h"
|
||||||
#include "gstinfo.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 **);
|
extern GstElement *_gst_parse_launch (const gchar *, GError **);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,21 +140,31 @@ gst_parse_launchv (const gchar ** argv, GError ** error)
|
||||||
GstElement *
|
GstElement *
|
||||||
gst_parse_launch (const gchar * pipeline_description, GError ** error)
|
gst_parse_launch (const gchar * pipeline_description, GError ** error)
|
||||||
{
|
{
|
||||||
GstElement *element = NULL;
|
GstElement *element;
|
||||||
static GStaticMutex flex_lock = G_STATIC_MUTEX_INIT;
|
|
||||||
|
|
||||||
g_return_val_if_fail (pipeline_description != NULL, NULL);
|
g_return_val_if_fail (pipeline_description != NULL, NULL);
|
||||||
|
|
||||||
GST_CAT_INFO (GST_CAT_PIPELINE, "parsing pipeline description %s",
|
GST_CAT_INFO (GST_CAT_PIPELINE, "parsing pipeline description %s",
|
||||||
pipeline_description);
|
pipeline_description);
|
||||||
|
|
||||||
/* the need for the mutex will go away with flex 2.5.6 */
|
g_static_rec_mutex_lock (&flex_lock);
|
||||||
if (g_static_mutex_trylock (&flex_lock)) {
|
if (flex_busy)
|
||||||
element = _gst_parse_launch (pipeline_description, error);
|
goto recursive_call;
|
||||||
g_static_mutex_unlock (&flex_lock);
|
flex_busy = TRUE;
|
||||||
} else {
|
|
||||||
GST_WARNING ("gst_parse_launch() cannot be nested");
|
element = _gst_parse_launch (pipeline_description, error);
|
||||||
}
|
|
||||||
|
flex_busy = FALSE;
|
||||||
|
g_static_rec_mutex_unlock (&flex_lock);
|
||||||
|
|
||||||
return element;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue