DBG("[thread] Thread manage kernel started");
+ /*
+ * This first step of the while is to clean this structure which could free
+ * non NULL pointers so zero it before the loop.
+ */
+ memset(&events, 0, sizeof(events));
+
if (testpoint(thread_manage_kernel)) {
goto error_testpoint;
}
health_code_update(&health_thread_kernel);
- ret = create_thread_poll_set(&events, 2);
- if (ret < 0) {
- goto error_poll_create;
- }
-
- ret = lttng_poll_add(&events, kernel_poll_pipe[0], LPOLLIN);
- if (ret < 0) {
- goto error;
- }
-
if (testpoint(thread_manage_kernel_before_loop)) {
- goto error;
+ goto error_testpoint;
}
while (1) {
health_code_update(&health_thread_kernel);
if (update_poll_flag == 1) {
- /*
- * Reset number of fd in the poll set. Always 2 since there is the thread
- * quit pipe and the kernel pipe.
- */
- events.nb_fd = 2;
+ /* Clean events object. We are about to populate it again. */
+ lttng_poll_clean(&events);
+
+ ret = create_thread_poll_set(&events, 2);
+ if (ret < 0) {
+ goto error_poll_create;
+ }
+
+ ret = lttng_poll_add(&events, kernel_poll_pipe[0], LPOLLIN);
+ if (ret < 0) {
+ goto error;
+ }
+ /* This will add the available kernel channel if any. */
ret = update_kernel_poll(&events);
if (ret < 0) {
goto error;
update_poll_flag = 0;
}
- DBG("Thread kernel polling on %d fds", events.nb_fd);
+ DBG("Thread kernel polling on %d fds", LTTNG_POLL_GETNB(&events));
/* Poll infinite value of time */
restart:
health_code_update(&health_thread_app_manage);
while (1) {
- DBG("Apps thread polling on %d fds", events.nb_fd);
+ DBG("Apps thread polling on %d fds", LTTNG_POLL_GETNB(&events));
/* Inifinite blocking call, waiting for transmission */
restart: