Run clang-format on the whole tree
[lttng-tools.git] / src / bin / lttng-sessiond / utils.cpp
CommitLineData
8e68d1c8 1/*
21cf9b6b 2 * Copyright (C) 2011 EfficiOS Inc.
ab5be9fa 3 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8e68d1c8 4 *
ab5be9fa 5 * SPDX-License-Identifier: GPL-2.0-only
8e68d1c8 6 *
8e68d1c8
DG
7 */
8
6c1c0768 9#define _LGPL_SOURCE
28ab034a
JG
10#include "lttng-sessiond.hpp"
11#include "snapshot.hpp"
12#include "utils.hpp"
8e68d1c8 13
c9e313bc 14#include <common/error.hpp>
7272acf5 15
28ab034a
JG
16#include <stdlib.h>
17#include <unistd.h>
0b2dc8df 18
54d01ffb
DG
19/*
20 * Write to writable pipe used to notify a thread.
21 */
22int notify_thread_pipe(int wpipe)
23{
6cd525e8 24 ssize_t ret;
54d01ffb 25
2f77fc4b
DG
26 /* Ignore if the pipe is invalid. */
27 if (wpipe < 0) {
28 return 0;
29 }
30
6cd525e8
MD
31 ret = lttng_write(wpipe, "!", 1);
32 if (ret < 1) {
8a00688e
MJ
33 ret = -1;
34 PERROR("Failed to write to thread pipe");
54d01ffb
DG
35 }
36
6cd525e8 37 return (int) ret;
54d01ffb
DG
38}
39
28ab034a
JG
40int loglevels_match(int a_loglevel_type,
41 int a_loglevel_value,
42 int b_loglevel_type,
43 int b_loglevel_value,
44 int loglevel_all_type)
19a97244
PP
45{
46 int match = 1;
47
48 if (a_loglevel_type == b_loglevel_type) {
49 /* Same loglevel type. */
50 if (b_loglevel_type != loglevel_all_type) {
51 /*
52 * Loglevel value must also match since the loglevel
53 * type is not all.
54 */
55 if (a_loglevel_value != b_loglevel_value) {
56 match = 0;
57 }
58 }
59 } else {
60 /* Loglevel type is different: no match. */
61 match = 0;
62 }
63
64 return match;
65}
a1ae2ea5
JD
66
67const char *session_get_base_path(const struct ltt_session *session)
68{
348a81dc 69 return consumer_output_get_base_path(session->consumer);
a1ae2ea5 70}
d2956687 71
348a81dc 72const char *consumer_output_get_base_path(const struct consumer_output *output)
d2956687 73{
28ab034a
JG
74 return output->type == CONSUMER_DST_LOCAL ? output->dst.session_root_path :
75 output->dst.net.base_dir;
d2956687 76}
This page took 0.081377 seconds and 4 git commands to generate.