X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fpython.c;h=0dae99d8242f69804a2c2b3e1ffee2e96b132aa9;hb=f66916deea905254061bb07245e007471faf2ecf;hp=27a1b25c4e1ecd14890cf6f81d8de7069ed26b81;hpb=46a35862cb9ff3caddad1fc01e02141b6e0a9f72;p=collectd.git diff --git a/src/python.c b/src/python.c index 27a1b25c..0dae99d8 100644 --- a/src/python.c +++ b/src/python.c @@ -665,12 +665,11 @@ static PyObject *cpy_register_generic_userdata(void *reg, void *handler, PyObjec c->data = data; c->next = NULL; - user_data_t user_data = { - .data = c, - .free_func = cpy_destroy_user_data - }; + register_function(buf, handler, &(user_data_t) { + .data = c, + .free_func = cpy_destroy_user_data, + }); - register_function(buf, handler, &user_data); ++cpy_num_callbacks; return cpy_string_to_unicode_or_bytes(buf); } @@ -704,13 +703,12 @@ static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwd c->data = data; c->next = NULL; - user_data_t user_data = { - .data = c, - .free_func = cpy_destroy_user_data - }; - plugin_register_complex_read(/* group = */ "python", buf, - cpy_read_callback, DOUBLE_TO_CDTIME_T (interval), &user_data); + cpy_read_callback, DOUBLE_TO_CDTIME_T (interval), + &(user_data_t) { + .data = c, + .free_func = cpy_destroy_user_data, + }); ++cpy_num_callbacks; return cpy_string_to_unicode_or_bytes(buf); } @@ -1022,10 +1020,12 @@ static int cpy_init(void) { ERROR("python: Unable to create pipe."); return 1; } - if (plugin_thread_create(&thread, NULL, cpy_interactive, pipefd + 1)) { + if (plugin_thread_create(&thread, NULL, cpy_interactive, pipefd + 1, + "python interpreter")) { ERROR("python: Error creating thread for interactive interpreter."); } - (void)read(pipefd[0], &buf, 1); + if(read(pipefd[0], &buf, 1)) + ; (void)close(pipefd[0]); } else { PyEval_InitThreads();