}
if (PyErr_Occurred() != NULL) {
cpy_log_exception("value building for write callback");
+ Py_DECREF(list);
CPY_RETURN_FROM_THREADS 0;
}
}
if (meta_data_get_boolean(meta, table[i], &b))
continue;
if (b)
- temp = Py_True;
+ PyDict_SetItemString(dict, table[i], Py_True);
else
- temp = Py_False;
- PyDict_SetItemString(dict, table[i], temp);
+ PyDict_SetItemString(dict, table[i], Py_False);
}
free(table[i]);
}
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));
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 {
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));
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 {
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) {