projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
eb165c5
)
python plugin: Unregister all internal callback lists before Python interpreter shutdown.
author
Sven Trenkel
<collectd@semidefinite.de>
Mon, 15 Aug 2016 18:55:44 +0000
(18:55 +0000)
committer
Sven Trenkel
<collectd@semidefinite.de>
Mon, 15 Aug 2016 18:55:44 +0000
(18:55 +0000)
src/python.c
patch
|
blob
|
history
diff --git
a/src/python.c
b/src/python.c
index
a555734
..
9405842
100644
(file)
--- a/
src/python.c
+++ b/
src/python.c
@@
-805,8
+805,8
@@
static PyObject *cpy_unregister_generic(cpy_callback_t **list_head, PyObject *ar
PyErr_Format(PyExc_RuntimeError, "Unable to unregister %s callback '%s'.", desc, name);
return NULL;
}
PyErr_Format(PyExc_RuntimeError, "Unable to unregister %s callback '%s'.", desc, name);
return NULL;
}
- /* Yes, this is actually sa
v
e. To call this function the caller has to
- * hold the GIL. Well, sa
v
e as long as there is only one GIL anyway ... */
+ /* Yes, this is actually sa
f
e. To call this function the caller has to
+ * hold the GIL. Well, sa
f
e as long as there is only one GIL anyway ... */
if (prev == NULL)
*list_head = tmp->next;
else
if (prev == NULL)
*list_head = tmp->next;
else
@@
-815,6
+815,15
@@
static PyObject *cpy_unregister_generic(cpy_callback_t **list_head, PyObject *ar
Py_RETURN_NONE;
}
Py_RETURN_NONE;
}
+static void cpy_unregister_list(cpy_callback_t **list_head) {
+ cpy_callback_t *cur, *next;
+ for (cur = *list_head; cur; cur = next) {
+ next = cur->next;
+ cpy_destroy_user_data(cur);
+ }
+ *list_head = NULL;
+}
+
typedef int cpy_unregister_function_t(const char *name);
static PyObject *cpy_unregister_generic_userdata(cpy_unregister_function_t *unreg, PyObject *arg, const char *desc) {
typedef int cpy_unregister_function_t(const char *name);
static PyObject *cpy_unregister_generic_userdata(cpy_unregister_function_t *unreg, PyObject *arg, const char *desc) {
@@
-916,6
+925,11
@@
static int cpy_shutdown(void) {
Py_DECREF(ret);
}
PyErr_Print();
Py_DECREF(ret);
}
PyErr_Print();
+
+ cpy_unregister_list(&cpy_config_callbacks);
+ cpy_unregister_list(&cpy_init_callbacks);
+ cpy_unregister_list(&cpy_shutdown_callbacks);
+
Py_Finalize();
return 0;
}
Py_Finalize();
return 0;
}
@@
-949,7
+963,7
@@
static void *cpy_interactive(void *data) {
if (PyImport_ImportModule("readline") == NULL) {
/* This interactive session will suck. */
cpy_log_exception("interactive session init");
if (PyImport_ImportModule("readline") == NULL) {
/* This interactive session will suck. */
cpy_log_exception("interactive session init");
- }
+ }
cur_sig = PyOS_setsig(SIGINT, python_sigint_handler);
/* We totally forked just now. Everyone saw that, right? */
PyOS_AfterFork();
cur_sig = PyOS_setsig(SIGINT, python_sigint_handler);
/* We totally forked just now. Everyone saw that, right? */
PyOS_AfterFork();