Cleanup: remove ignored flags from poll events bitmasks
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 11 Nov 2020 15:38:51 +0000 (10:38 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 28 Oct 2022 20:57:16 +0000 (16:57 -0400)
The POLLHUP and POLLERR flags are only valid in 'revents', they are
implicitly enabled regardless of the fact they were set in 'events' or not.

As such remove those flags from all poll events to reduce possible
confusion as to which flags can be returned by poll.

Change-Id: Id22c78c38257d96dfc47e1337795f13c70dd5f91
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
17 files changed:
src/bin/lttng-relayd/thread-utils.cpp
src/bin/lttng-sessiond/agent-thread.cpp
src/bin/lttng-sessiond/client.cpp
src/bin/lttng-sessiond/dispatch.cpp
src/bin/lttng-sessiond/health.cpp
src/bin/lttng-sessiond/manage-apps.cpp
src/bin/lttng-sessiond/manage-consumer.cpp
src/bin/lttng-sessiond/notification-thread-events.cpp
src/bin/lttng-sessiond/notification-thread.cpp
src/bin/lttng-sessiond/notify-apps.cpp
src/bin/lttng-sessiond/rotation-thread.cpp
src/bin/lttng-sessiond/thread-utils.cpp
src/common/consumer/consumer.cpp
src/lib/lttng-ctl/channel.cpp
src/lib/lttng-ctl/clear.cpp
src/lib/lttng-ctl/destruction-handle.cpp
tests/unit/test_utils_compat_poll.cpp

index d469f90e55f67b28730c64955aacfb4757716682..25ea256d5a31100d1b6c9429f89d04744abeb5bb 100644 (file)
@@ -92,7 +92,7 @@ int create_named_thread_poll_set(struct lttng_poll_event *events,
        }
 
        /* Add thread quit pipe to monitored events. */
-       const auto poll_add_ret = lttng_poll_add(events, thread_quit_pipe[0], LPOLLIN | LPOLLERR);
+       const auto poll_add_ret = lttng_poll_add(events, thread_quit_pipe[0], LPOLLIN);
        if (poll_add_ret < 0) {
                return -1;
        }
index dc8cb2961228e93584d70bde9f67015bb43b8a81..e54a7cecf6f450ec1e1594b42e9edb2e01a45b8b 100644 (file)
@@ -377,8 +377,7 @@ static void *thread_agent_management(void *data)
                goto error_poll_create;
        }
 
-       ret = lttng_poll_add(&events, thread_quit_pipe_fd,
-                       LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN);
        if (ret < 0) {
                goto error_tcp_socket;
        }
@@ -411,8 +410,7 @@ static void *thread_agent_management(void *data)
        mark_thread_as_ready(notifiers);
 
        /* Add TCP socket to the poll set. */
-       ret = lttng_poll_add(&events, reg_sock->fd,
-                       LPOLLIN | LPOLLERR | LPOLLHUP | LPOLLRDHUP);
+       ret = lttng_poll_add(&events, reg_sock->fd, LPOLLIN | LPOLLRDHUP);
        if (ret < 0) {
                goto error;
        }
@@ -484,8 +482,7 @@ restart:
                                 * read), only add poll error event to only
                                 * detect shutdown.
                                 */
-                               ret = lttng_poll_add(&events, new_app_socket_fd,
-                                               LPOLLERR | LPOLLHUP | LPOLLRDHUP);
+                               ret = lttng_poll_add(&events, new_app_socket_fd, LPOLLRDHUP);
                                if (ret < 0) {
                                        agent_destroy_app(new_app);
                                        continue;
index 4c4cdf54092a6212c76a8dbbd0a01e656a743b4f..f33648fcc3b1541bb5970905c601ebd074ad22bd 100644 (file)
@@ -2501,7 +2501,7 @@ static void *thread_manage_clients(void *data)
        }
 
        /* Add thread quit pipe */
-       ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN);
        if (ret < 0) {
                goto error;
        }
index 82bf1c2d3128a026a0d8eb62b18eb9a4b2e70353..a8e8d6c8d44d48f3b712ceac08129fc86d0ac316 100644 (file)
@@ -113,8 +113,7 @@ static void sanitize_wait_queue(struct ust_reg_wait_queue *wait_queue)
        cds_list_for_each_entry_safe(wait_node, tmp_wait_node,
                        &wait_queue->head, head) {
                LTTNG_ASSERT(wait_node->app);
-               ret = lttng_poll_add(&events, wait_node->app->sock,
-                               LPOLLHUP | LPOLLERR);
+               ret = lttng_poll_add(&events, wait_node->app->sock, LPOLLIN);
                if (ret < 0) {
                        goto error;
                }
index 1ba991447bd5223e17b61cdfe3767692ef9810d5..6457cb31b12d8e4d6bb525863c01b83757703c2a 100644 (file)
@@ -122,7 +122,7 @@ static void *thread_manage_health(void *data)
                goto error;
        }
 
-       ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN);
        if (ret < 0) {
                goto error;
        }
index 7698ea442feff54e2bc8902334f70f93d8270b98..ea46f05277ca9aad79297afda111a2d1be461181 100644 (file)
@@ -75,7 +75,7 @@ static void *thread_application_management(void *data)
                goto error;
        }
 
-       ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN);
        if (ret < 0) {
                goto error;
        }
@@ -142,8 +142,7 @@ static void *thread_application_management(void *data)
                                         * Since this is a command socket (write then read),
                                         * we only monitor the error events of the socket.
                                         */
-                                       ret = lttng_poll_add(&events, sock,
-                                                       LPOLLERR | LPOLLHUP | LPOLLRDHUP);
+                                       ret = lttng_poll_add(&events, sock, LPOLLRDHUP);
                                        if (ret < 0) {
                                                goto error;
                                        }
index d9d1e670ec87e2da1f356c4dc2930db6005a1c83..ae1529e9be5a76c851db52a8aad28e0d5cfd5b7f 100644 (file)
@@ -83,7 +83,7 @@ static void *thread_consumer_management(void *data)
                goto error_poll;
        }
 
-       ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN);
        if (ret < 0) {
                mark_thread_intialization_as_failed(notifiers);
                goto error;
index 6fb691be59f91d54e3c9107731ee9ee560670e30..64c3fc4f3f03d1d1116b04237a03cbbb4c8cbd83 100644 (file)
@@ -48,7 +48,7 @@
 #include "lttng-sessiond.hpp"
 #include "kernel.hpp"
 
-#define CLIENT_POLL_EVENTS_IN (LPOLLIN | LPOLLERR | LPOLLHUP | LPOLLRDHUP)
+#define CLIENT_POLL_EVENTS_IN (LPOLLIN | LPOLLRDHUP)
 #define CLIENT_POLL_EVENTS_IN_OUT (CLIENT_POLL_EVENTS_IN | LPOLLOUT)
 
 /* The tracers currently limit the capture size to PIPE_BUF (4kb on linux). */
@@ -2208,7 +2208,7 @@ int handle_notification_thread_command_add_tracer_event_source(
                        lttng_domain_type_str(domain_type));
 
        /* Adding the read side pipe to the event poll. */
-       ret = lttng_poll_add(&state->events, tracer_event_source_fd, LPOLLPRI | LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(&state->events, tracer_event_source_fd, LPOLLPRI | LPOLLIN);
        if (ret < 0) {
                ERR("Failed to add tracer event source to poll set: tracer_event_source_fd = %d, domain = '%s'",
                                tracer_event_source_fd,
index 7d9f4ed12dd72bae638db763f757ee8ffa7021a0..320e639d0468bf917af7e3327c868c211e10a48d 100644 (file)
@@ -292,28 +292,24 @@ int init_poll_set(struct lttng_poll_event *poll_set,
                goto end;
        }
 
-       ret = lttng_poll_add(poll_set, notification_channel_socket,
-                       LPOLLIN | LPOLLERR | LPOLLHUP | LPOLLRDHUP);
+       ret = lttng_poll_add(poll_set, notification_channel_socket, LPOLLIN | LPOLLRDHUP);
        if (ret < 0) {
                ERR("Failed to add notification channel socket to pollset");
                goto error;
        }
-       ret = lttng_poll_add(poll_set, handle->cmd_queue.event_fd,
-                       LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(poll_set, handle->cmd_queue.event_fd, LPOLLIN);
        if (ret < 0) {
                ERR("Failed to add notification command queue event fd to pollset");
                goto error;
        }
        ret = lttng_poll_add(poll_set,
-                       handle->channel_monitoring_pipes.ust32_consumer,
-                       LPOLLIN | LPOLLERR);
+                       handle->channel_monitoring_pipes.ust32_consumer, LPOLLIN);
        if (ret < 0) {
                ERR("Failed to add ust-32 channel monitoring pipe fd to pollset");
                goto error;
        }
        ret = lttng_poll_add(poll_set,
-                       handle->channel_monitoring_pipes.ust64_consumer,
-                       LPOLLIN | LPOLLERR);
+                       handle->channel_monitoring_pipes.ust64_consumer, LPOLLIN);
        if (ret < 0) {
                ERR("Failed to add ust-64 channel monitoring pipe fd to pollset");
                goto error;
@@ -322,8 +318,7 @@ int init_poll_set(struct lttng_poll_event *poll_set,
                goto end;
        }
        ret = lttng_poll_add(poll_set,
-                       handle->channel_monitoring_pipes.kernel_consumer,
-                       LPOLLIN | LPOLLERR);
+                       handle->channel_monitoring_pipes.kernel_consumer, LPOLLIN);
        if (ret < 0) {
                ERR("Failed to add kernel channel monitoring pipe fd to pollset");
                goto error;
index 1b83491d14b920686898a77a0f249bda42223520..ff70ac187dcaff606ee0e8e73b97c18d99e53a7b 100644 (file)
@@ -58,13 +58,12 @@ static void *thread_application_notification(void *data)
 
        /* Add notify pipe to the pollset. */
        ret = lttng_poll_add(&events, notifiers->apps_cmd_notify_pipe_read_fd,
-                       LPOLLIN | LPOLLERR | LPOLLHUP | LPOLLRDHUP);
+                       LPOLLIN | LPOLLRDHUP);
        if (ret < 0) {
                goto error;
        }
 
-       ret = lttng_poll_add(&events, thread_quit_pipe_fd,
-                       LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN);
        if (ret < 0) {
                goto error;
        }
@@ -121,8 +120,7 @@ restart:
                                        }
                                        health_code_update();
 
-                                       ret = lttng_poll_add(&events, sock,
-                                                       LPOLLIN | LPOLLERR | LPOLLHUP | LPOLLRDHUP);
+                                       ret = lttng_poll_add(&events, sock, LPOLLIN | LPOLLRDHUP);
                                        if (ret < 0) {
                                                /*
                                                 * It's possible we've reached the max poll fd allowed.
index 22891dd13ec4d5f20c99d10aa650c0fe0af65e7c..aa6ba07800d6dac81340405c6023e9d9d4dc3fa1 100644 (file)
@@ -257,8 +257,7 @@ int init_poll_set(struct lttng_poll_event *poll_set,
        }
 
        ret = lttng_poll_add(poll_set,
-                       lttng_pipe_get_readfd(handle->quit_pipe),
-                       LPOLLIN | LPOLLERR);
+                       lttng_pipe_get_readfd(handle->quit_pipe), LPOLLIN);
        if (ret < 0) {
                ERR("Failed to add quit pipe read fd to poll set");
                goto error;
@@ -266,7 +265,7 @@ int init_poll_set(struct lttng_poll_event *poll_set,
 
        ret = lttng_poll_add(poll_set,
                        lttng_pipe_get_readfd(handle->rotation_timer_queue->event_pipe),
-                       LPOLLIN | LPOLLERR);
+                       LPOLLIN);
        if (ret < 0) {
                ERR("Failed to add rotate_pending fd to poll set");
                goto error;
@@ -310,7 +309,7 @@ int init_thread_state(struct rotation_thread_handle *handle,
                goto end;
        }
        ret = lttng_poll_add(&state->events, rotate_notification_channel->socket,
-                       LPOLLIN | LPOLLERR);
+                       LPOLLIN);
        if (ret < 0) {
                ERR("Failed to add notification fd to pollset");
                goto end;
index 1b8ff0881b68cbb0276037952078dff60e20e60a..3465fc227bd2ae13c55920ebf75779db7208f9a3 100644 (file)
@@ -65,7 +65,7 @@ int sessiond_wait_for_main_quit_pipe(int timeout_ms)
                ret = -1;
                goto end;
        }
-       ret = lttng_poll_add(&events, main_quit_pipe[0], LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(&events, main_quit_pipe[0], LPOLLIN);
        if (ret < 0) {
                PERROR("Failed to add file descriptor to poll/epoll set");
                ret = -1;
@@ -114,7 +114,7 @@ int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size)
        }
 
        /* Add main quit pipe */
-       ret = lttng_poll_add(events, main_quit_pipe[0], LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(events, main_quit_pipe[0], LPOLLIN);
        if (ret < 0) {
                goto error;
        }
index c1abb58df616f036e3f76a9a13959c74d217883b..f97c119705451c1f2080e99327de6488e9283062 100644 (file)
@@ -2428,9 +2428,8 @@ restart:
                                                        stream->wait_fd);
 
                                        /* Add metadata stream to the global poll events list */
-                                       lttng_poll_add(&events, stream->wait_fd,
-                                                       LPOLLIN | LPOLLPRI | LPOLLHUP);
-                               } else if (revents & (LPOLLERR | LPOLLHUP)) {
+                                       lttng_poll_add(&events, stream->wait_fd, LPOLLIN | LPOLLPRI);
+                               }else if (revents & (LPOLLERR | LPOLLHUP)) {
                                        DBG("Metadata thread pipe hung up");
                                        /*
                                         * Remove the pipe from the poll set and continue the loop
@@ -3020,8 +3019,8 @@ restart:
                                                                &chan->wait_fd_node);
                                                rcu_read_unlock();
                                                /* Add channel to the global poll events list */
-                                               lttng_poll_add(&events, chan->wait_fd,
-                                                               LPOLLERR | LPOLLHUP);
+                                               // FIXME: Empty flag on a pipe pollset, this might hang on FreeBSD.
+                                               lttng_poll_add(&events, chan->wait_fd, 0);
                                                break;
                                        case CONSUMER_CHANNEL_DEL:
                                        {
index 3613f1b1cde5e1912edead013894811660d4c5a7..aee38f58bfa41bafebd5fce22c5d26d12c590a6f 100644 (file)
@@ -268,7 +268,7 @@ lttng_notification_channel_get_next_notification(
                status = LTTNG_NOTIFICATION_CHANNEL_STATUS_ERROR;
                goto end_unlock;
        }
-       ret = lttng_poll_add(&events, channel->socket, LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(&events, channel->socket, LPOLLIN);
        if (ret < 0) {
                status = LTTNG_NOTIFICATION_CHANNEL_STATUS_ERROR;
                goto end_clean_poll;
@@ -448,7 +448,7 @@ lttng_notification_channel_has_pending_notification(
                status = LTTNG_NOTIFICATION_CHANNEL_STATUS_ERROR;
                goto end_unlock;
        }
-       ret = lttng_poll_add(&events, channel->socket, LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(&events, channel->socket, LPOLLIN);
        if (ret < 0) {
                status = LTTNG_NOTIFICATION_CHANNEL_STATUS_ERROR;
                goto end_clean_poll;
index b205ac8f2b8af75e8584d5ba3b378f9c9f2562c9..870935bd3280d527ace8d40444d43ea5d3864eb3 100644 (file)
@@ -77,7 +77,7 @@ struct lttng_clear_handle *lttng_clear_handle_create(int sessiond_socket)
        }
 
        ret = lttng_poll_add(&handle->communication.events, sessiond_socket,
-                       LPOLLIN | LPOLLHUP | LPOLLRDHUP | LPOLLERR);
+                       LPOLLIN | LPOLLRDHUP);
        if (ret) {
                goto error;
        }
index 04cbd92a59c4aa71862b6398abc3de52210e13ca..688e4faba652dd023d47f9ff131fab9ee8b8e3f6 100644 (file)
@@ -82,7 +82,7 @@ struct lttng_destruction_handle *lttng_destruction_handle_create(
        }
 
        ret = lttng_poll_add(&handle->communication.events, sessiond_socket,
-                       LPOLLIN | LPOLLHUP | LPOLLRDHUP | LPOLLERR);
+                       LPOLLIN | LPOLLRDHUP);
        if (ret) {
                goto error;
        }
index f34ef5d0ea27f7da28484eafcfef21416c6e66b8..697440963c58279514129e0515b00d425d75eb61 100644 (file)
@@ -147,7 +147,7 @@ static void test_mod_wait(void)
                childok(lttng_poll_create(&cpoll_events, 1, 0) == 0, "Create valid poll set succeeds");
                childok(lttng_poll_mod(NULL, infd[0], LPOLLIN) == -1, "lttng_poll_mod with invalid input returns an error");
                childok(lttng_poll_mod(&cpoll_events, infd[0], LPOLLIN) == -1, "lttng_poll_mod with invalid input returns an error");
-               childok(lttng_poll_add(&cpoll_events, infd[0], LPOLLHUP) == 0, "Add valid FD succeeds");
+               childok(lttng_poll_add(&cpoll_events, infd[0], LPOLLIN) == 0, "Add valid FD succeeds");
                childok(lttng_poll_mod(&cpoll_events, -1, LPOLLIN) == -1, "lttng_poll_mod with invalid input returns an error");
                childok(lttng_poll_mod(&cpoll_events, hupfd[0], LPOLLIN) == 0, "lttng_poll_mod on unincluded FD goes on");
                childok(lttng_poll_mod(&cpoll_events, infd[0], LPOLLIN) == 0, "Modify event type succeeds");
@@ -169,7 +169,7 @@ static void test_mod_wait(void)
 
                ok(lttng_poll_create(&poll_events, 1, 0) == 0, "Create valid poll set succeeds");
                ok(lttng_poll_wait(&poll_events, -1) == -1, "lttng_poll_wait call with invalid input returns error");
-               ok(lttng_poll_add(&poll_events, hupfd[0], LPOLLHUP) == 0, "Add valid FD succeeds");
+               ok(lttng_poll_add(&poll_events, hupfd[0], LPOLLIN) == 0, "Add valid FD succeeds");
                ok(lttng_write(infd[1], &tbuf, 1) == 1, "Write to pipe succeeds");
                ok(lttng_poll_wait(&poll_events, -1) == 1, "Wakes up on one event");
                ok(lttng_poll_del(&poll_events, hupfd[0]) == 0, "Removing valid FD succeeds");
This page took 0.035512 seconds and 4 git commands to generate.