Commit | Line | Data |
---|---|---|
8e68d1c8 | 1 | /* |
ab5be9fa MJ |
2 | * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca> |
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 |
8e68d1c8 | 10 | #include <stdlib.h> |
8e68d1c8 DG |
11 | #include <unistd.h> |
12 | ||
db758600 | 13 | #include <common/error.h> |
7272acf5 | 14 | |
8e68d1c8 | 15 | #include "utils.h" |
d2956687 | 16 | #include "snapshot.h" |
0b2dc8df MD |
17 | #include "lttng-sessiond.h" |
18 | ||
412d7227 | 19 | int the_ht_cleanup_pipe[2] = {-1, -1}; |
8e68d1c8 | 20 | |
54d01ffb DG |
21 | /* |
22 | * Write to writable pipe used to notify a thread. | |
23 | */ | |
24 | int notify_thread_pipe(int wpipe) | |
25 | { | |
6cd525e8 | 26 | ssize_t ret; |
54d01ffb | 27 | |
2f77fc4b DG |
28 | /* Ignore if the pipe is invalid. */ |
29 | if (wpipe < 0) { | |
30 | return 0; | |
31 | } | |
32 | ||
6cd525e8 MD |
33 | ret = lttng_write(wpipe, "!", 1); |
34 | if (ret < 1) { | |
7272acf5 | 35 | PERROR("write poll pipe"); |
54d01ffb DG |
36 | } |
37 | ||
6cd525e8 | 38 | return (int) ret; |
54d01ffb DG |
39 | } |
40 | ||
0b2dc8df MD |
41 | void ht_cleanup_push(struct lttng_ht *ht) |
42 | { | |
6cd525e8 | 43 | ssize_t ret; |
412d7227 | 44 | int fd = the_ht_cleanup_pipe[1]; |
0b2dc8df | 45 | |
e7e84b72 JG |
46 | if (!ht) { |
47 | return; | |
48 | } | |
5de62fd8 JG |
49 | if (fd < 0) |
50 | return; | |
6cd525e8 MD |
51 | ret = lttng_write(fd, &ht, sizeof(ht)); |
52 | if (ret < sizeof(ht)) { | |
0b2dc8df MD |
53 | PERROR("write ht cleanup pipe %d", fd); |
54 | if (ret < 0) { | |
55 | ret = -errno; | |
56 | } | |
57 | goto error; | |
58 | } | |
59 | ||
60 | /* All good. Don't send back the write positive ret value. */ | |
61 | ret = 0; | |
62 | error: | |
63 | assert(!ret); | |
64 | } | |
19a97244 PP |
65 | |
66 | int loglevels_match(int a_loglevel_type, int a_loglevel_value, | |
67 | int b_loglevel_type, int b_loglevel_value, int loglevel_all_type) | |
68 | { | |
69 | int match = 1; | |
70 | ||
71 | if (a_loglevel_type == b_loglevel_type) { | |
72 | /* Same loglevel type. */ | |
73 | if (b_loglevel_type != loglevel_all_type) { | |
74 | /* | |
75 | * Loglevel value must also match since the loglevel | |
76 | * type is not all. | |
77 | */ | |
78 | if (a_loglevel_value != b_loglevel_value) { | |
79 | match = 0; | |
80 | } | |
81 | } | |
82 | } else { | |
83 | /* Loglevel type is different: no match. */ | |
84 | match = 0; | |
85 | } | |
86 | ||
87 | return match; | |
88 | } | |
a1ae2ea5 JD |
89 | |
90 | const char *session_get_base_path(const struct ltt_session *session) | |
91 | { | |
348a81dc | 92 | return consumer_output_get_base_path(session->consumer); |
a1ae2ea5 | 93 | } |
d2956687 | 94 | |
348a81dc | 95 | const char *consumer_output_get_base_path(const struct consumer_output *output) |
d2956687 | 96 | { |
348a81dc JG |
97 | return output->type == CONSUMER_DST_LOCAL ? |
98 | output->dst.session_root_path : | |
99 | output->dst.net.base_dir; | |
d2956687 | 100 | } |