From 268ec049968538c7a3176159fc992b07ebe69af1 Mon Sep 17 00:00:00 2001 From: Christian Babeux Date: Sun, 2 Dec 2012 22:09:28 -0500 Subject: [PATCH] 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 --- src/bin/lttng-sessiond/main.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) 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; + + } } } } -- 2.34.1