|
Panu Matilainen |
1c9fae |
changeset: 6178:e9ced408b17f
|
|
Panu Matilainen |
1c9fae |
tag: tip
|
|
Panu Matilainen |
1c9fae |
user: Panu Matilainen <pmatilai@redhat.com>
|
|
Panu Matilainen |
1c9fae |
date: Fri Jul 20 11:23:11 2007 +0300
|
|
Panu Matilainen |
1c9fae |
files: python/rpmmodule.c
|
|
Panu Matilainen |
1c9fae |
description:
|
|
Panu Matilainen |
1c9fae |
Force rpmdb clean termination on exit from python.
|
|
Panu Matilainen |
1c9fae |
Python process tracebacking with active iterators can and will otherwise leave
|
|
Panu Matilainen |
1c9fae |
stale locks around (as is presumably the reason for rhbz#235389 and various
|
|
Panu Matilainen |
1c9fae |
other locking issues)
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
diff -r 6acd7701e4df -r e9ced408b17f python/rpmmodule.c
|
|
Panu Matilainen |
1c9fae |
--- a/python/rpmmodule.c Fri Jul 20 11:19:56 2007 +0300
|
|
Panu Matilainen |
1c9fae |
+++ b/python/rpmmodule.c Fri Jul 20 11:23:11 2007 +0300
|
|
Panu Matilainen |
1c9fae |
@@ -227,6 +227,16 @@ static PyMethodDef rpmModuleMethods[] =
|
|
Panu Matilainen |
1c9fae |
{ NULL }
|
|
Panu Matilainen |
1c9fae |
} ;
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
+/*
|
|
Panu Matilainen |
1c9fae |
+* Force clean up of open iterators and dbs on exit.
|
|
Panu Matilainen |
1c9fae |
+* This ends up calling exit() while we're already exiting but exit
|
|
Panu Matilainen |
1c9fae |
+* handlers will only get called once so it wont loop.
|
|
Panu Matilainen |
1c9fae |
+*/
|
|
Panu Matilainen |
1c9fae |
+static void rpm_exithook(void)
|
|
Panu Matilainen |
1c9fae |
+{
|
|
Panu Matilainen |
1c9fae |
+ rpmdbCheckTerminate(1);
|
|
Panu Matilainen |
1c9fae |
+}
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
/**
|
|
Panu Matilainen |
1c9fae |
*/
|
|
Panu Matilainen |
1c9fae |
static char rpm__doc__[] =
|
|
Panu Matilainen |
1c9fae |
@@ -263,6 +273,13 @@ void init_rpm(void)
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
m = Py_InitModule3("_rpm", rpmModuleMethods, rpm__doc__);
|
|
Panu Matilainen |
1c9fae |
if (m == NULL)
|
|
Panu Matilainen |
1c9fae |
+ return;
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+ /*
|
|
Panu Matilainen |
1c9fae |
+ * treat error to register rpm cleanup hook as fatal, tracebacks
|
|
Panu Matilainen |
1c9fae |
+ * can and will leave stale locks around if we can't clean up
|
|
Panu Matilainen |
1c9fae |
+ */
|
|
Panu Matilainen |
1c9fae |
+ if (Py_AtExit(rpm_exithook) == -1)
|
|
Panu Matilainen |
1c9fae |
return;
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
rpmReadConfigFiles(NULL, NULL);
|
|
Panu Matilainen |
1c9fae |
|