Cygwin: Fix fd hangup in thread_manage_apps of sessiond
authorChristian Babeux <christian.babeux@efficios.com>
Mon, 3 Dec 2012 03:09:28 +0000 (22:09 -0500)
committerChristian Babeux <christian.babeux@efficios.com>
Fri, 7 Dec 2012 20:17:55 +0000 (15:17 -0500)
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 <christian.babeux@efficios.com>
src/bin/lttng-sessiond/main.c

index d735be833f4064e88d0cd801a45c6d781d618c55..7225495547b2276d0df20dfaac64f415fb434b54 100644 (file)
@@ -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;
+
+                                       }
                                }
                        }
                }
This page took 0.027871 seconds and 4 git commands to generate.