Fix concurrency issues while overwriting tracefiles in live
[lttng-tools.git] / src / bin / lttng-relayd / index.h
CommitLineData
1c20f0e2
JD
1/*
2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License, version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#ifndef _RELAY_INDEX_H
20#define _RELAY_INDEX_H
21
22#include <inttypes.h>
23#include <pthread.h>
24
25#include <common/hashtable/hashtable.h>
26#include <common/index/index.h>
27
28struct relay_index {
29 /* FD on which to write the index data. */
30 int fd;
31 /*
32 * When destroying this object, this fd is checked and if valid, close it
33 * so this is basically a lazy close of the previous fd corresponding to
34 * the same stream id. This is used for the rotate file feature.
35 */
36 int to_close_fd;
37
38 /* Index packet data. This is the data that is written on disk. */
39 struct lttng_packet_index index_data;
40
41 /* key1 = stream_id, key2 = net_seq_num */
42 struct lttng_ht_two_u64 key;
43 struct lttng_ht_node_two_u64 index_n;
44 struct rcu_head rcu_node;
45 pthread_mutex_t mutex;
46};
47
48struct relay_index *relay_index_create(uint64_t stream_id,
49 uint64_t net_seq_num);
0a6518b0
DG
50struct relay_index *relay_index_find(uint64_t stream_id, uint64_t net_seq_num);
51void relay_index_add(struct relay_index *index, struct relay_index **_index);
52int relay_index_write(int fd, struct relay_index *index);
1c20f0e2
JD
53void relay_index_free(struct relay_index *index);
54void relay_index_free_safe(struct relay_index *index);
0a6518b0
DG
55void relay_index_delete(struct relay_index *index);
56void relay_index_destroy_by_stream_id(uint64_t stream_id);
1c20f0e2
JD
57
58#endif /* _RELAY_INDEX_H */
This page took 0.024908 seconds and 4 git commands to generate.