X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=ltt-sessiond%2Fmain.c;h=d61cd7bc512f3c7dbb682950e55ff448db0507f4;hb=856117389ea3a46acbefdc4a27b9f4f8b1cf5179;hp=c9522d697f5cc698217b94dc495312af7ee9c7d2;hpb=28ba3f4e591845d044b329db5ac80e9558ed1fc8;p=lttng-tools.git diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index c9522d697..d61cd7bc5 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -567,6 +567,8 @@ static int update_kernel_pollfd(void) /* Adding the quit pipe */ kernel_pollfd[nb_fd - 1].fd = thread_quit_pipe[0]; + kernel_pollfd[nb_fd - 1].events = + POLLHUP | POLLNVAL | POLLERR | POLLIN | POLLRDHUP | POLLPRI; return nb_fd; @@ -667,6 +669,8 @@ static void *thread_manage_kernel(void *data) goto error; } else if (ret == 0) { /* Should not happen since timeout is infinite */ + ERR("Return value of poll is 0 with an infinite timeout.\n" + "This should not have happened! Continuing..."); continue; } @@ -860,6 +864,9 @@ static int update_apps_cmd_pollfd(unsigned int nb_fd, unsigned int old_nb_fd, /* First fd is always the quit pipe */ (*pollfd)[0].fd = thread_quit_pipe[0]; + (*pollfd)[0].events = + POLLHUP | POLLNVAL | POLLERR | POLLIN | POLLRDHUP | POLLPRI; + /* Apps command pipe */ (*pollfd)[1].fd = apps_cmd_pipe[0]; (*pollfd)[1].events = POLLIN; @@ -880,6 +887,16 @@ static int update_apps_cmd_pollfd(unsigned int nb_fd, unsigned int old_nb_fd, } } + if (nb_fd < 2) { + /* + * There should *always* be at least two fds in the pollfd. This safety + * check make sure the poll() will actually try on those two pipes at + * best which are the thread_quit_pipe and apps_cmd_pipe. + */ + nb_fd = 2; + MSG("nb_fd < 2 --> Not good! Continuing..."); + } + /* Destroy old pollfd */ free(old_pollfd); @@ -1096,6 +1113,8 @@ static void *thread_registration_apps(void *data) /* First fd is always the quit pipe */ pollfd[0].fd = thread_quit_pipe[0]; + pollfd[0].events = + POLLHUP | POLLNVAL | POLLERR | POLLIN | POLLRDHUP | POLLPRI; /* Apps socket */ pollfd[1].fd = apps_sock; @@ -2610,6 +2629,8 @@ static void *thread_manage_clients(void *data) /* First fd is always the quit pipe */ pollfd[0].fd = thread_quit_pipe[0]; + pollfd[0].events = + POLLHUP | POLLNVAL | POLLERR | POLLIN | POLLRDHUP | POLLPRI; /* Apps socket */ pollfd[1].fd = client_sock;