Code

python: Fixed a crash if the plugin was loaded but not configured.
authorSven Trenkel <collectd@semidefinite.de>
Mon, 3 May 2010 13:01:56 +0000 (15:01 +0200)
committerSven Trenkel <collectd@semidefinite.de>
Mon, 3 May 2010 13:01:56 +0000 (15:01 +0200)
src/python.c

index d750d95b503e7fbbff9e78c375eeef3e809e79be..7a92b4853422f1e3788c45abc0fb6f2a50289e6e 100644 (file)
@@ -828,6 +828,11 @@ static int cpy_init(void) {
        static pthread_t thread;
        sigset_t sigset;
        
+       if (!Py_IsInitialized()) {
+               WARNING("python: Plugin loaded but not configured.");
+               plugin_unregister_shutdown("python");
+               return 0;
+       }
        PyEval_InitThreads();
        /* Now it's finally OK to use python threads. */
        for (c = cpy_init_callbacks; c; c = c->next) {