sessiond: ust: conditionally enable the underscore prefix variant quirk
[lttng-tools.git] / src / bin / lttng-sessiond / notify-apps.cpp
index 0e799ff261a5b11d0822004e5293f0b0c96d1a77..ff70ac187dcaff606ee0e8e73b97c18d99e53a7b 100644 (file)
@@ -7,33 +7,35 @@
 
 #define _LGPL_SOURCE
 
-#include <common/common.h>
-#include <common/utils.h>
-
-#include "fd-limit.h"
-#include "lttng-sessiond.h"
-#include "notify-apps.h"
-#include "health-sessiond.h"
-#include "testpoint.h"
-#include "utils.h"
-#include "thread.h"
-
+#include <common/common.hpp>
+#include <common/utils.hpp>
+
+#include "fd-limit.hpp"
+#include "lttng-sessiond.hpp"
+#include "notify-apps.hpp"
+#include "health-sessiond.hpp"
+#include "testpoint.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
+
+namespace {
 struct thread_notifiers {
        struct lttng_pipe *quit_pipe;
        int apps_cmd_notify_pipe_read_fd;
 };
+} /* namespace */
 
 /*
  * This thread manage application notify communication.
  */
 static void *thread_application_notification(void *data)
 {
-       int i, ret, pollfd, err = -1;
+       int i, ret, err = -1;
        ssize_t size_ret;
-       uint32_t revents, nb_fd;
+       uint32_t nb_fd;
        struct lttng_poll_event events;
        struct thread_notifiers *notifiers = (thread_notifiers *) data;
-       const int quit_pipe_read_fd = lttng_pipe_get_readfd(notifiers->quit_pipe);
+       const auto thread_quit_pipe_fd = lttng_pipe_get_readfd(notifiers->quit_pipe);
 
        DBG("[ust-thread] Manage application notify command");
 
@@ -56,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, quit_pipe_read_fd,
-                       LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN);
        if (ret < 0) {
                goto error;
        }
@@ -95,14 +96,17 @@ restart:
                        health_code_update();
 
                        /* Fetch once the poll data */
-                       revents = LTTNG_POLL_GETEV(&events, i);
-                       pollfd = LTTNG_POLL_GETFD(&events, i);
+                       const auto revents = LTTNG_POLL_GETEV(&events, i);
+                       const auto pollfd = LTTNG_POLL_GETFD(&events, i);
 
-                       /* Thread quit pipe has been closed. Killing thread. */
-                       if (pollfd == quit_pipe_read_fd) {
+                       /* Activity on thread quit pipe, exiting. */
+                       if (pollfd == thread_quit_pipe_fd) {
+                               DBG("Activity on thread quit pipe");
                                err = 0;
                                goto exit;
-                       } else if (pollfd == notifiers->apps_cmd_notify_pipe_read_fd) {
+                       }
+
+                       if (pollfd == notifiers->apps_cmd_notify_pipe_read_fd) {
                                /* Inspect the apps cmd pipe */
                                int sock;
 
@@ -116,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.
@@ -212,7 +215,7 @@ bool launch_application_notification_thread(int apps_cmd_notify_pipe_read_fd)
        struct thread_notifiers *notifiers;
        struct lttng_pipe *quit_pipe;
 
-       notifiers = (thread_notifiers *) zmalloc(sizeof(*notifiers));
+       notifiers = zmalloc<thread_notifiers>();
        if (!notifiers) {
                goto error_alloc;
        }
This page took 0.025444 seconds and 4 git commands to generate.