2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
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.
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
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.
19 #ifndef _RELAY_INDEX_H
20 #define _RELAY_INDEX_H
25 #include <common/hashtable/hashtable.h>
26 #include <common/index/index.h>
29 /* FD on which to write the index data. */
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.
38 /* Index packet data. This is the data that is written on disk. */
39 struct lttng_packet_index index_data
;
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
;
48 struct relay_index
*relay_index_create(uint64_t stream_id
,
49 uint64_t net_seq_num
);
50 struct relay_index
*relay_index_find(uint64_t stream_id
, uint64_t net_seq_num
);
51 void relay_index_add(struct relay_index
*index
, struct relay_index
**_index
);
52 int relay_index_write(int fd
, struct relay_index
*index
);
53 void relay_index_free(struct relay_index
*index
);
54 void relay_index_free_safe(struct relay_index
*index
);
55 void relay_index_delete(struct relay_index
*index
);
56 void relay_index_destroy_by_stream_id(uint64_t stream_id
);
58 #endif /* _RELAY_INDEX_H */