From: Sven Trenkel Date: Wed, 19 May 2010 08:58:01 +0000 (+0200) Subject: Merge branch 'collectd-4.9' into collectd-4.10 X-Git-Tag: collectd-4.10.1~11 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=fabc18dac7e676b4e6577bcb6880d501dccc5b31;hp=7970f59dff204401069cfc53f7c53f207a681428;p=collectd.git Merge branch 'collectd-4.9' into collectd-4.10 Conflicts: src/python.c --- diff --git a/configure.in b/configure.in index c4350276..13a1f9dd 100644 --- a/configure.in +++ b/configure.in @@ -967,7 +967,7 @@ fi AC_MSG_CHECKING([if have htonll defined]) have_htonll="no" - AC_RUN_IFELSE([ + AC_LINK_IFELSE([ AC_LANG_PROGRAM([ #include #include diff --git a/src/python.c b/src/python.c index 00516fb2..6be727ef 100644 --- a/src/python.c +++ b/src/python.c @@ -371,6 +371,7 @@ static int cpy_write_callback(const data_set_t *ds, const value_list_t *value_li } if (PyErr_Occurred() != NULL) { cpy_log_exception("value building for write callback"); + Py_DECREF(list); CPY_RETURN_FROM_THREADS 0; } } @@ -427,7 +428,7 @@ static int cpy_write_callback(const data_set_t *ds, const value_list_t *value_li } free(table); } - v = PyObject_New(Values, (void *) &ValuesType); + v = PyObject_New(Values, (void *) &ValuesType); /* New reference. */ sstrncpy(v->data.host, value_list->host, sizeof(v->data.host)); sstrncpy(v->data.type, value_list->type, sizeof(v->data.type)); sstrncpy(v->data.type_instance, value_list->type_instance, sizeof(v->data.type_instance)); @@ -438,6 +439,7 @@ static int cpy_write_callback(const data_set_t *ds, const value_list_t *value_li v->values = list; v->meta = dict; ret = PyObject_CallFunctionObjArgs(c->callback, v, c->data, (void *) 0); /* New reference. */ + Py_XDECREF(v); if (ret == NULL) { cpy_log_exception("write callback"); } else { @@ -453,7 +455,7 @@ static int cpy_notification_callback(const notification_t *notification, user_da Notification *n; CPY_LOCK_THREADS - n = PyObject_New(Notification, (void *) &NotificationType); + n = PyObject_New(Notification, (void *) &NotificationType); /* New reference. */ sstrncpy(n->data.host, notification->host, sizeof(n->data.host)); sstrncpy(n->data.type, notification->type, sizeof(n->data.type)); sstrncpy(n->data.type_instance, notification->type_instance, sizeof(n->data.type_instance)); @@ -463,6 +465,7 @@ static int cpy_notification_callback(const notification_t *notification, user_da sstrncpy(n->message, notification->message, sizeof(n->message)); n->severity = notification->severity; ret = PyObject_CallFunctionObjArgs(c->callback, n, c->data, (void *) 0); /* New reference. */ + Py_XDECREF(n); if (ret == NULL) { cpy_log_exception("notification callback"); } else { @@ -896,6 +899,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) {