Fix: handle EINTR for every read()
authorDavid Goulet <dgoulet@efficios.com>
Tue, 18 Dec 2012 20:30:25 +0000 (15:30 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 18 Dec 2012 20:30:25 +0000 (15:30 -0500)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-relayd/main.c
src/bin/lttng-sessiond/main.c

index a3eef148810e3219d1978edeacfe1e2434d46690..47780e2660c59a22ccf3e32c88cf3dd7a98ef12d 100644 (file)
@@ -1818,7 +1818,9 @@ int relay_add_connection(int fd, struct lttng_poll_event *events,
                PERROR("Relay command zmalloc");
                goto error;
        }
-       ret = read(fd, relay_connection, sizeof(struct relay_command));
+       do {
+               ret = read(fd, relay_connection, sizeof(struct relay_command));
+       } while (ret < 0 && errno == EINTR);
        if (ret < 0 || ret < sizeof(struct relay_command)) {
                PERROR("read relay cmd pipe");
                goto error_read;
index 6e548f3c10bf8185c13ac8156f1b5c54fe0ff4ce..477a9413b71692d8630572dc8ab6de49b5534bad 100644 (file)
@@ -772,7 +772,13 @@ static void *thread_manage_kernel(void *data)
 
                        /* Check for data on kernel pipe */
                        if (pollfd == kernel_poll_pipe[0] && (revents & LPOLLIN)) {
-                               ret = read(kernel_poll_pipe[0], &tmp, 1);
+                               do {
+                                       ret = read(kernel_poll_pipe[0], &tmp, 1);
+                               } while (ret < 0 && errno == EINTR);
+                               /*
+                                * Ret value is useless here, if this pipe gets any actions an
+                                * update is required anyway.
+                                */
                                update_poll_flag = 1;
                                continue;
                        } else {
@@ -1166,7 +1172,9 @@ static void *thread_manage_apps(void *data)
                                        goto error;
                                } else if (revents & LPOLLIN) {
                                        /* Empty pipe */
-                                       ret = read(apps_cmd_pipe[0], &ust_cmd, sizeof(ust_cmd));
+                                       do {
+                                               ret = read(apps_cmd_pipe[0], &ust_cmd, sizeof(ust_cmd));
+                                       } while (ret < 0 && errno == EINTR);
                                        if (ret < 0 || ret < sizeof(ust_cmd)) {
                                                PERROR("read apps cmd pipe");
                                                goto error;
This page took 0.039086 seconds and 4 git commands to generate.