Fix: define _LGPL_SOURCE in C files
[lttng-tools.git] / src / bin / lttng-sessiond / utils.c
... / ...
CommitLineData
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 *
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.
8 *
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.
13 *
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.
17 */
18
19#define _GNU_SOURCE
20#define _LGPL_SOURCE
21#include <stdlib.h>
22#include <unistd.h>
23
24#include <common/error.h>
25
26#include "utils.h"
27#include "lttng-sessiond.h"
28
29int ht_cleanup_pipe[2] = { -1, -1 };
30
31/*
32 * Write to writable pipe used to notify a thread.
33 */
34int notify_thread_pipe(int wpipe)
35{
36 ssize_t ret;
37
38 /* Ignore if the pipe is invalid. */
39 if (wpipe < 0) {
40 return 0;
41 }
42
43 ret = lttng_write(wpipe, "!", 1);
44 if (ret < 1) {
45 PERROR("write poll pipe");
46 }
47
48 return (int) ret;
49}
50
51void ht_cleanup_push(struct lttng_ht *ht)
52{
53 ssize_t ret;
54 int fd = ht_cleanup_pipe[1];
55
56 if (!ht) {
57 return;
58 }
59 if (fd < 0)
60 return;
61 ret = lttng_write(fd, &ht, sizeof(ht));
62 if (ret < sizeof(ht)) {
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}
This page took 0.025037 seconds and 5 git commands to generate.