Fix: sessiond: no rotation performed from null chunk to new chunk
[lttng-tools.git] / src / bin / lttng-sessiond / utils.c
CommitLineData
8e68d1c8 1/*
996b65c8 2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
1e307fab 3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8e68d1c8 4 *
d14d33bf
AM
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License, version 2 only,
7 * as published by the Free Software Foundation.
8e68d1c8 8 *
d14d33bf
AM
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
8e68d1c8 13 *
d14d33bf
AM
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
8e68d1c8
DG
17 */
18
6c1c0768 19#define _LGPL_SOURCE
8e68d1c8 20#include <stdlib.h>
8e68d1c8
DG
21#include <unistd.h>
22
db758600 23#include <common/error.h>
7272acf5 24
8e68d1c8 25#include "utils.h"
d2956687 26#include "snapshot.h"
0b2dc8df
MD
27#include "lttng-sessiond.h"
28
29int ht_cleanup_pipe[2] = { -1, -1 };
8e68d1c8 30
54d01ffb
DG
31/*
32 * Write to writable pipe used to notify a thread.
33 */
34int notify_thread_pipe(int wpipe)
35{
6cd525e8 36 ssize_t ret;
54d01ffb 37
2f77fc4b
DG
38 /* Ignore if the pipe is invalid. */
39 if (wpipe < 0) {
40 return 0;
41 }
42
6cd525e8
MD
43 ret = lttng_write(wpipe, "!", 1);
44 if (ret < 1) {
7272acf5 45 PERROR("write poll pipe");
54d01ffb
DG
46 }
47
6cd525e8 48 return (int) ret;
54d01ffb
DG
49}
50
0b2dc8df
MD
51void ht_cleanup_push(struct lttng_ht *ht)
52{
6cd525e8 53 ssize_t ret;
0b2dc8df
MD
54 int fd = ht_cleanup_pipe[1];
55
e7e84b72
JG
56 if (!ht) {
57 return;
58 }
5de62fd8
JG
59 if (fd < 0)
60 return;
6cd525e8
MD
61 ret = lttng_write(fd, &ht, sizeof(ht));
62 if (ret < sizeof(ht)) {
0b2dc8df
MD
63 PERROR("write ht cleanup pipe %d", fd);
64 if (ret < 0) {
65 ret = -errno;
66 }
67 goto error;
68 }
69
70 /* All good. Don't send back the write positive ret value. */
71 ret = 0;
72error:
73 assert(!ret);
74}
19a97244
PP
75
76int loglevels_match(int a_loglevel_type, int a_loglevel_value,
77 int b_loglevel_type, int b_loglevel_value, int loglevel_all_type)
78{
79 int match = 1;
80
81 if (a_loglevel_type == b_loglevel_type) {
82 /* Same loglevel type. */
83 if (b_loglevel_type != loglevel_all_type) {
84 /*
85 * Loglevel value must also match since the loglevel
86 * type is not all.
87 */
88 if (a_loglevel_value != b_loglevel_value) {
89 match = 0;
90 }
91 }
92 } else {
93 /* Loglevel type is different: no match. */
94 match = 0;
95 }
96
97 return match;
98}
a1ae2ea5
JD
99
100const char *session_get_base_path(const struct ltt_session *session)
101{
348a81dc 102 return consumer_output_get_base_path(session->consumer);
a1ae2ea5 103}
d2956687 104
348a81dc 105const char *consumer_output_get_base_path(const struct consumer_output *output)
d2956687 106{
348a81dc
JG
107 return output->type == CONSUMER_DST_LOCAL ?
108 output->dst.session_root_path :
109 output->dst.net.base_dir;
d2956687 110}
This page took 0.062361 seconds and 4 git commands to generate.