[gst-cvs] gst-python: registry: fix deadlock with recursive registry scanning.
Edward Hervey
bilboed at kemper.freedesktop.org
Sun Apr 12 12:26:53 PDT 2009
Module: gst-python
Branch: master
Commit: bbedab4e6521fe7c813f23698fe650203b1d0820
URL: http://cgit.freedesktop.org/gstreamer/gst-python/commit/?id=bbedab4e6521fe7c813f23698fe650203b1d0820
Author: Edward Hervey <bilboed at bilboed.com>
Date: Sun Apr 12 21:27:33 2009 +0200
registry: fix deadlock with recursive registry scanning.
The way to properly fix this issue was in fact to disable the registry
scanning when we import gst from the python plugin loader since...
we are 100% guaranteed this is being called from a registry scan :)
---
gst/__init__.py | 10 ----------
plugin/gstpythonplugin.c | 15 +++++++++++++++
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/gst/__init__.py b/gst/__init__.py
index d843d43..f29ede2 100644
--- a/gst/__init__.py
+++ b/gst/__init__.py
@@ -190,11 +190,6 @@ try:
except:
pass
-# disable registry update during initialization
-import os
-doupdate = os.getenv("GST_REGISTRY_UPDATE") != "no"
-os.environ["GST_REGISTRY_UPDATE"] = "no"
-
from _gst import *
import interfaces
@@ -232,8 +227,3 @@ if gstlibtoolimporter is not None:
gstlibtoolimporter.uninstall()
import sys
del sys.modules["gstlibtoolimporter"]
-
-if doupdate:
- # update the registry now that we've loaded all symbols
- os.unsetenv("GST_REGISTRY_UPDATE")
- update_registry()
diff --git a/plugin/gstpythonplugin.c b/plugin/gstpythonplugin.c
index dc3f0e2..a090e40 100644
--- a/plugin/gstpythonplugin.c
+++ b/plugin/gstpythonplugin.c
@@ -253,6 +253,8 @@ pygst_require (gchar * version)
PyObject *pygst, *gst;
PyObject *require;
PyObject *modules;
+ gboolean doupdate = TRUE;
+ const gchar *regupd;
modules = PySys_GetObject ("modules");
/* Try to see if 'gst' is already imported */
@@ -273,12 +275,25 @@ pygst_require (gchar * version)
goto error;
}
}
+
+ /* We don't want the registry to be loaded when we import gst */
+ if ((regupd = g_getenv ("GST_REGISTRY_UPDATE"))
+ && (!g_strcmp0 (regupd, "no")))
+ doupdate = FALSE;
+ g_setenv ("GST_REGISTRY_UPDATE", "no", TRUE);
+
if (!(gst = PyImport_ImportModule ("gst"))) {
GST_ERROR ("couldn't import the gst module");
Py_DECREF (pygst);
+ if (doupdate)
+ g_unsetenv ("GST_REGISTRY_UPDATE");
goto error;
}
}
+
+ if (doupdate)
+ g_unsetenv ("GST_REGISTRY_UPDATE");
+
#define IMPORT(x, y) \
_PyGst##x##_Type = (PyTypeObject *)PyObject_GetAttrString(gst, y); \
if (_PyGst##x##_Type == NULL) { \
More information about the Gstreamer-commits
mailing list