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 d750d95..7a92b48 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) {