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>
28 enum consumer_dst_type
{
33 struct consumer_data
{
34 enum lttng_consumer_type type
;
36 pthread_t thread
; /* Worker thread interacting with the consumer */
39 /* Mutex to control consumerd pid assignation */
40 pthread_mutex_t pid_mutex
;
46 /* consumer error and command Unix socket path */
47 char err_unix_sock_path
[PATH_MAX
];
48 char cmd_unix_sock_path
[PATH_MAX
];
50 /* Health check of the thread */
51 struct health_state health
;
59 * Indicate if URI type is set. Those flags should only be set when the
60 * created URI is done AND valid.
66 * The following two URIs MUST have the same destination address for
67 * network streaming to work. Network hop are not yet supported.
70 /* Control path for network streaming. */
71 struct lttng_uri control
;
73 /* Data path for network streaming. */
74 struct lttng_uri data
;
78 * Consumer output object describing where and how to send data.
80 struct consumer_output
{
81 /* Consumer socket file descriptor */
83 /* If the consumer is enabled meaning that should be used */
85 enum consumer_dst_type type
;
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.
93 * Subdirectory path name used for both local and network consumer.
95 char subdir
[PATH_MAX
];
97 char trace_path
[PATH_MAX
];
98 struct consumer_net net
;
102 struct consumer_output
*consumer_create_output(enum consumer_dst_type type
);
103 struct consumer_output
*consumer_copy_output(struct consumer_output
*obj
);
104 void consumer_destroy_output(struct consumer_output
*obj
);
105 int consumer_set_network_uri(struct consumer_output
*obj
,
106 struct lttng_uri
*uri
);
107 int consumer_send_fds(int sock
, int *fds
, size_t nb_fd
);
108 int consumer_send_stream(int sock
, struct consumer_output
*dst
,
109 struct lttcomm_consumer_msg
*msg
, int *fds
, size_t nb_fd
);
110 int consumer_send_channel(int sock
, struct lttcomm_consumer_msg
*msg
);
111 int consumer_send_relayd_socket(int consumer_sock
,
112 struct lttcomm_sock
*sock
, struct consumer_output
*consumer
,
113 enum lttng_stream_type type
);
115 void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg
*msg
,
116 enum lttng_consumer_command cmd
,
120 enum lttng_event_output output
,
125 unsigned int metadata_flag
,
127 const char *pathname
);
128 void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg
*msg
,
129 enum lttng_consumer_command cmd
,
131 uint64_t max_sb_size
,
135 #endif /* _CONSUMER_H */