#include <common/pipe.hpp>
#include <common/utils.hpp>
+#include <fcntl.h>
#include <signal.h>
namespace {
struct thread_notifiers *notifiers = (thread_notifiers *) data;
struct consumer_data *consumer_data = notifiers->consumer_data;
const auto thread_quit_pipe_fd = lttng_pipe_get_readfd(notifiers->quit_pipe);
- struct consumer_socket *cmd_socket_wrapper = NULL;
+ struct consumer_socket *cmd_socket_wrapper = nullptr;
DBG("[thread] Manage consumer started");
/* Create metadata socket lock. */
consumer_data->metadata_sock.lock = zmalloc<pthread_mutex_t>();
- if (consumer_data->metadata_sock.lock == NULL) {
+ if (consumer_data->metadata_sock.lock == nullptr) {
PERROR("zmalloc pthread mutex");
mark_thread_intialization_as_failed(notifiers);
goto error;
}
- pthread_mutex_init(consumer_data->metadata_sock.lock, NULL);
+ pthread_mutex_init(consumer_data->metadata_sock.lock, nullptr);
DBG("Consumer command socket ready (fd: %d)", consumer_data->cmd_sock);
DBG("Consumer metadata socket ready (fd: %d)", consumer_data->metadata_fd);
/* Discard the socket wrapper as it is no longer needed. */
consumer_destroy_socket(cmd_socket_wrapper);
- cmd_socket_wrapper = NULL;
+ cmd_socket_wrapper = nullptr;
/* The thread is completely initialized, signal that it is ready. */
mark_thread_as_ready(notifiers);
/* Infinite blocking call, waiting for transmission */
- while (1) {
+ while (true) {
health_code_update();
/* Exit the thread because the thread quit pipe has been triggered. */
rcu_thread_offline();
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
static bool shutdown_consumer_management_thread(void *data)
bool launch_consumer_management_thread(struct consumer_data *consumer_data)
{
struct lttng_pipe *quit_pipe;
- struct thread_notifiers *notifiers = NULL;
+ struct thread_notifiers *notifiers = nullptr;
struct lttng_thread *thread;
notifiers = zmalloc<thread_notifiers>();
}
wait_until_thread_is_ready(notifiers);
lttng_thread_put(thread);
- if (notifiers->initialization_result) {
- return false;
- }
- return true;
+ return notifiers->initialization_result == 0;
error:
cleanup_consumer_management_thread(notifiers);
error_alloc: