From: Christian Babeux Date: Mon, 3 Dec 2012 03:09:28 +0000 (-0500) Subject: Cygwin: Fix fd hangup in thread_manage_apps of sessiond X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=268ec049968538c7a3176159fc992b07ebe69af1;p=lttng-tools.git Cygwin: Fix fd hangup in thread_manage_apps of sessiond The fd hangup is not properly detected in the thread that manage applications in the sessiond. A read is done on the fd and if we encounter EOF, we force the removal of the fd from the set. Signed-off-by: Christian Babeux --- diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index d735be833..722549554 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -1287,16 +1287,27 @@ static void *thread_manage_apps(void *data) * At this point, we know that a registered application made * the event at poll_wait. */ - if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) { - /* Removing from the poll set */ - ret = lttng_poll_del(&events, pollfd); - if (ret < 0) { - goto error; - } - /* Socket closed on remote end. */ - ust_app_unregister(pollfd); - break; + if (revents & (LPOLLIN | LPOLLERR | LPOLLHUP | LPOLLRDHUP)) { + ssize_t readlen; + char dummy; + + do { + readlen = read(pollfd, &dummy, 1); + } while (readlen == -1 && errno == EINTR); + + if (readlen == 0) { + /* Removing from the poll set */ + ret = lttng_poll_del(&events, pollfd); + if (ret < 0) { + goto error; + } + + /* Socket closed on remote end. */ + ust_app_unregister(pollfd); + break; + + } } } }