From: David Goulet Date: Tue, 6 Sep 2011 21:10:42 +0000 (-0400) Subject: Fix pollfd update bug in thread_manage apps X-Git-Tag: v2.0-pre13~15 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=28ba3f4e591845d044b329db5ac80e9558ed1fc8;hp=7d0510346384fe2e67e9d3ffc132b05c4612c032 Fix pollfd update bug in thread_manage apps When updating the pollfd array, the wrong pollfd size was used so at multiple UST registration at the same time the socket was not added to the poll list. Signed-off-by: David Goulet --- diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 85ac06be9..c9522d697 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -899,7 +899,7 @@ error: */ static void *thread_manage_apps(void *data) { - int i, ret, count; + int i, ret, current_nb_fd; unsigned int nb_fd = 2; int update_poll_flag = 1; struct pollfd *pollfd = NULL; @@ -908,6 +908,7 @@ static void *thread_manage_apps(void *data) DBG("[thread] Manage application started"); ust_cmd.sock = -1; + current_nb_fd = nb_fd; while (1) { /* See if we have a valid socket to add to pollfd */ @@ -918,7 +919,7 @@ static void *thread_manage_apps(void *data) /* The pollfd struct must be updated */ if (update_poll_flag) { - ret = update_apps_cmd_pollfd(nb_fd, ARRAY_SIZE(pollfd), &pollfd); + ret = update_apps_cmd_pollfd(nb_fd, current_nb_fd, &pollfd); if (ret < 0) { /* malloc failed so we quit */ goto error; @@ -978,8 +979,8 @@ static void *thread_manage_apps(void *data) } } - count = nb_fd; - for (i = 2; i < count; i++) { + current_nb_fd = nb_fd; + for (i = 2; i < current_nb_fd; i++) { /* Apps socket is closed/hungup */ switch (pollfd[i].revents) { case POLLERR: @@ -994,7 +995,7 @@ static void *thread_manage_apps(void *data) } } - if (nb_fd != count) { + if (nb_fd != current_nb_fd) { update_poll_flag = 1; } }