2 * Copyright (C) 2012 - David Goulet <dgoulet@efficios.com>
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.
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
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.
21 #include <semaphore.h>
23 #include <common/consumer.h>
24 #include <lttng/lttng.h>
26 enum consumer_dst_type
{
31 struct consumer_data
{
32 enum lttng_consumer_type type
;
34 pthread_t thread
; /* Worker thread interacting with the consumer */
37 /* Mutex to control consumerd pid assignation */
38 pthread_mutex_t pid_mutex
;
44 /* consumer error and command Unix socket path */
45 char err_unix_sock_path
[PATH_MAX
];
46 char cmd_unix_sock_path
[PATH_MAX
];
54 * Indicate if URI type is set. Those flags should only be set when the
55 * created URI is done AND valid.
61 * The following two URIs MUST have the same destination address for
62 * network streaming to work. Network hop are not yet supported.
65 /* Control path for network streaming. */
66 struct lttng_uri control
;
68 /* Data path for network streaming. */
69 struct lttng_uri data
;
73 * Consumer output object describing where and how to send data.
75 struct consumer_output
{
76 /* Consumer socket file descriptor */
78 /* If the consumer is enabled meaning that should be used */
80 enum consumer_dst_type type
;
82 * The net_seq_index is the index of the network stream on the consumer
83 * side. It's basically the relayd socket file descriptor value so the
84 * consumer can identify which streams goes with which socket.
88 * Subdirectory path name used for both local and network consumer.
90 char subdir
[PATH_MAX
];
92 char trace_path
[PATH_MAX
];
93 struct consumer_net net
;
97 struct consumer_output
*consumer_create_output(enum consumer_dst_type type
);
98 struct consumer_output
*consumer_copy_output(struct consumer_output
*obj
);
99 void consumer_destroy_output(struct consumer_output
*obj
);
100 int consumer_set_network_uri(struct consumer_output
*obj
,
101 struct lttng_uri
*uri
);
102 int consumer_send_fds(int sock
, int *fds
, size_t nb_fd
);
103 int consumer_send_stream(int sock
, struct consumer_output
*dst
,
104 struct lttcomm_consumer_msg
*msg
, int *fds
, size_t nb_fd
);
105 int consumer_send_channel(int sock
, struct lttcomm_consumer_msg
*msg
);
106 void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg
*msg
,
107 enum lttng_consumer_command cmd
,
111 enum lttng_event_output output
,
116 unsigned int metadata_flag
,
118 const char *pathname
);
119 void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg
*msg
,
120 enum lttng_consumer_command cmd
,
122 uint64_t max_sb_size
,
126 #endif /* _CONSUMER_H */