lttng-relayd.h: review update
[lttng-tools.git] / src / bin / lttng-sessiond / consumer.h
CommitLineData
f1e16794
DG
1/*
2 * Copyright (C) 2012 - David Goulet <dgoulet@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18#ifndef _CONSUMER_H
19#define _CONSUMER_H
20
21#include <semaphore.h>
22
23#include <common/consumer.h>
00e2e675
DG
24#include <lttng/lttng.h>
25
44a5e5eb
DG
26#include "health.h"
27
00e2e675
DG
28enum consumer_dst_type {
29 CONSUMER_DST_LOCAL,
30 CONSUMER_DST_NET,
31};
f1e16794
DG
32
33struct consumer_data {
34 enum lttng_consumer_type type;
35
36 pthread_t thread; /* Worker thread interacting with the consumer */
37 sem_t sem;
38
39 /* Mutex to control consumerd pid assignation */
40 pthread_mutex_t pid_mutex;
41 pid_t pid;
42
43 int err_sock;
44 int cmd_sock;
45
46 /* consumer error and command Unix socket path */
47 char err_unix_sock_path[PATH_MAX];
48 char cmd_unix_sock_path[PATH_MAX];
44a5e5eb
DG
49
50 /* Health check of the thread */
51 struct health_state health;
f1e16794
DG
52};
53
00e2e675
DG
54/*
55 * Network URIs
56 */
57struct consumer_net {
58 /*
59 * Indicate if URI type is set. Those flags should only be set when the
60 * created URI is done AND valid.
61 */
62 int control_isset;
63 int data_isset;
64
65 /*
66 * The following two URIs MUST have the same destination address for
67 * network streaming to work. Network hop are not yet supported.
68 */
69
70 /* Control path for network streaming. */
71 struct lttng_uri control;
72
73 /* Data path for network streaming. */
74 struct lttng_uri data;
75};
76
77/*
78 * Consumer output object describing where and how to send data.
79 */
80struct consumer_output {
81 /* Consumer socket file descriptor */
82 int sock;
83 /* If the consumer is enabled meaning that should be used */
84 unsigned int enabled;
85 enum consumer_dst_type type;
86 /*
87 * The net_seq_index is the index of the network stream on the consumer
88 * side. It's basically the relayd socket file descriptor value so the
89 * consumer can identify which streams goes with which socket.
90 */
91 int net_seq_index;
92 /*
93 * Subdirectory path name used for both local and network consumer.
94 */
95 char subdir[PATH_MAX];
96 union {
97 char trace_path[PATH_MAX];
98 struct consumer_net net;
99 } dst;
100};
101
102struct consumer_output *consumer_create_output(enum consumer_dst_type type);
103struct consumer_output *consumer_copy_output(struct consumer_output *obj);
104void consumer_destroy_output(struct consumer_output *obj);
105int consumer_set_network_uri(struct consumer_output *obj,
106 struct lttng_uri *uri);
107int consumer_send_fds(int sock, int *fds, size_t nb_fd);
108int consumer_send_stream(int sock, struct consumer_output *dst,
109 struct lttcomm_consumer_msg *msg, int *fds, size_t nb_fd);
110int consumer_send_channel(int sock, struct lttcomm_consumer_msg *msg);
111void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg,
112 enum lttng_consumer_command cmd,
113 int channel_key,
114 int stream_key,
115 uint32_t state,
116 enum lttng_event_output output,
117 uint64_t mmap_len,
118 uid_t uid,
119 gid_t gid,
120 int net_index,
121 unsigned int metadata_flag,
122 const char *name,
123 const char *pathname);
124void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg,
125 enum lttng_consumer_command cmd,
126 int channel_key,
127 uint64_t max_sb_size,
128 uint64_t mmap_len,
129 const char *name);
130
f1e16794 131#endif /* _CONSUMER_H */
This page took 0.038867 seconds and 4 git commands to generate.