projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
240b010
)
python plugin: Properly deal with identifier being NULL in a log callback.
author
Sven Trenkel
<collectd@semidefinite.de>
Mon, 15 Aug 2016 18:53:28 +0000
(18:53 +0000)
committer
Sven Trenkel
<collectd@semidefinite.de>
Mon, 15 Aug 2016 18:53:28 +0000
(18:53 +0000)
src/python.c
patch
|
blob
|
history
diff --git
a/src/python.c
b/src/python.c
index
a682f31
..
a555734
100644
(file)
--- a/
src/python.c
+++ b/
src/python.c
@@
-197,7
+197,7
@@
static char reg_flush_doc[] = "register_flush(callback[, data][, name]) -> ident
"The callback function will be called with two or three parameters:\n"
"timeout: Indicates that only data older than 'timeout' seconds is to\n"
" be flushed.\n"
"The callback function will be called with two or three parameters:\n"
"timeout: Indicates that only data older than 'timeout' seconds is to\n"
" be flushed.\n"
- "id: Specifies which values are to be flushed.\n"
+ "id: Specifies which values are to be flushed.
Might be None.
\n"
"data: The optional data parameter passed to the register function.\n"
" If the parameter was omitted it will be omitted here, too.";
"data: The optional data parameter passed to the register function.\n"
" If the parameter was omitted it will be omitted here, too.";
@@
-520,7
+520,12
@@
static void cpy_flush_callback(int timeout, const char *id, user_data_t *data) {
PyObject *ret, *text;
CPY_LOCK_THREADS
PyObject *ret, *text;
CPY_LOCK_THREADS
- text = cpy_string_to_unicode_or_bytes(id);
+ if (id) {
+ text = cpy_string_to_unicode_or_bytes(id);
+ } else {
+ text = Py_None;
+ Py_INCREF(text);
+ }
if (c->data == NULL)
ret = PyObject_CallFunction(c->callback, "iN", timeout, text); /* New reference. */
else
if (c->data == NULL)
ret = PyObject_CallFunction(c->callback, "iN", timeout, text); /* New reference. */
else