Fix: remove assertions of the existence of a trace chunk
[lttng-tools.git] / src / common / relayd / relayd.c
CommitLineData
00e2e675
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
6c1c0768 18#define _LGPL_SOURCE
00e2e675
DG
19#include <assert.h>
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <sys/stat.h>
77c7c900 24#include <inttypes.h>
00e2e675
DG
25
26#include <common/common.h>
27#include <common/defaults.h>
f263b7fd 28#include <common/compat/endian.h>
27283937 29#include <common/compat/string.h>
00e2e675 30#include <common/sessiond-comm/relayd.h>
50adc264 31#include <common/index/ctf-index.h>
d2956687 32#include <common/trace-chunk.h>
00e2e675
DG
33
34#include "relayd.h"
35
36/*
37 * Send command. Fill up the header and append the data.
38 */
6151a90f 39static int send_command(struct lttcomm_relayd_sock *rsock,
76b9afaa 40 enum lttcomm_relayd_command cmd, const void *data, size_t size,
00e2e675
DG
41 int flags)
42{
43 int ret;
44 struct lttcomm_relayd_hdr header;
45 char *buf;
46 uint64_t buf_size = sizeof(header);
47
f96e4545
MD
48 if (rsock->sock.fd < 0) {
49 return -ECONNRESET;
50 }
51
00e2e675
DG
52 if (data) {
53 buf_size += size;
54 }
55
56 buf = zmalloc(buf_size);
57 if (buf == NULL) {
58 PERROR("zmalloc relayd send command buf");
59 ret = -1;
60 goto alloc_error;
61 }
62
53efb85a 63 memset(&header, 0, sizeof(header));
00e2e675
DG
64 header.cmd = htobe32(cmd);
65 header.data_size = htobe64(size);
66
67 /* Zeroed for now since not used. */
68 header.cmd_version = 0;
69 header.circuit_id = 0;
70
71 /* Prepare buffer to send. */
72 memcpy(buf, &header, sizeof(header));
73 if (data) {
74 memcpy(buf + sizeof(header), data, size);
75 }
76
06586bbe 77 DBG3("Relayd sending command %d of size %" PRIu64, (int) cmd, buf_size);
6151a90f 78 ret = rsock->sock.ops->sendmsg(&rsock->sock, buf, buf_size, flags);
00e2e675 79 if (ret < 0) {
06586bbe
JG
80 PERROR("Failed to send command %d of size %" PRIu64,
81 (int) cmd, buf_size);
8994307f 82 ret = -errno;
00e2e675
DG
83 goto error;
84 }
00e2e675
DG
85error:
86 free(buf);
87alloc_error:
88 return ret;
89}
90
91/*
92 * Receive reply data on socket. This MUST be call after send_command or else
93 * could result in unexpected behavior(s).
94 */
6151a90f 95static int recv_reply(struct lttcomm_relayd_sock *rsock, void *data, size_t size)
00e2e675
DG
96{
97 int ret;
98
f96e4545
MD
99 if (rsock->sock.fd < 0) {
100 return -ECONNRESET;
101 }
102
8fd623e0 103 DBG3("Relayd waiting for reply of size %zu", size);
00e2e675 104
6151a90f 105 ret = rsock->sock.ops->recvmsg(&rsock->sock, data, size, 0);
20275fe8
DG
106 if (ret <= 0 || ret != size) {
107 if (ret == 0) {
108 /* Orderly shutdown. */
6151a90f 109 DBG("Socket %d has performed an orderly shutdown", rsock->sock.fd);
20275fe8 110 } else {
8fd623e0 111 DBG("Receiving reply failed on sock %d for size %zu with ret %d",
6151a90f 112 rsock->sock.fd, size, ret);
20275fe8
DG
113 }
114 /* Always return -1 here and the caller can use errno. */
115 ret = -1;
00e2e675
DG
116 goto error;
117 }
118
119error:
120 return ret;
121}
122
d3e2ba59 123/*
f86f6389
JR
124 * Starting from 2.11, RELAYD_CREATE_SESSION payload (session_name & hostname)
125 * have no length restriction on the sender side.
126 * Length for both payloads is stored in the msg struct. A new dynamic size
127 * payload size is introduced.
128 */
129static int relayd_create_session_2_11(struct lttcomm_relayd_sock *rsock,
fb9a95c4 130 const char *session_name, const char *hostname,
658f12fa 131 int session_live_timer, unsigned int snapshot,
f39bd140 132 uint64_t sessiond_session_id, const lttng_uuid sessiond_uuid,
db1da059
JG
133 const uint64_t *current_chunk_id,
134 time_t creation_time)
f86f6389
JR
135{
136 int ret;
137 struct lttcomm_relayd_create_session_2_11 *msg = NULL;
138 size_t session_name_len;
139 size_t hostname_len;
140 size_t msg_length;
141
142 /* The two names are sent with a '\0' delimiter between them. */
143 session_name_len = strlen(session_name) + 1;
144 hostname_len = strlen(hostname) + 1;
145
146 msg_length = sizeof(*msg) + session_name_len + hostname_len;
147 msg = zmalloc(msg_length);
148 if (!msg) {
149 PERROR("zmalloc create_session_2_11 command message");
150 ret = -1;
151 goto error;
152 }
153
154 assert(session_name_len <= UINT32_MAX);
155 msg->session_name_len = htobe32(session_name_len);
156
157 assert(hostname_len <= UINT32_MAX);
158 msg->hostname_len = htobe32(hostname_len);
159
160 if (lttng_strncpy(msg->names, session_name, session_name_len)) {
161 ret = -1;
162 goto error;
163 }
164 if (lttng_strncpy(msg->names + session_name_len, hostname, hostname_len)) {
165 ret = -1;
166 goto error;
167 }
168
169 msg->live_timer = htobe32(session_live_timer);
170 msg->snapshot = !!snapshot;
171
658f12fa
JG
172 lttng_uuid_copy(msg->sessiond_uuid, sessiond_uuid);
173 msg->session_id = htobe64(sessiond_session_id);
174
f39bd140
JG
175 if (current_chunk_id) {
176 LTTNG_OPTIONAL_SET(&msg->current_chunk_id,
177 htobe64(*current_chunk_id));
178 }
179
db1da059
JG
180 msg->creation_time = htobe64((uint64_t) creation_time);
181
f86f6389
JR
182 /* Send command */
183 ret = send_command(rsock, RELAYD_CREATE_SESSION, msg, msg_length, 0);
184 if (ret < 0) {
185 goto error;
186 }
187error:
188 free(msg);
189 return ret;
190}
191/*
192 * From 2.4 to 2.10, RELAYD_CREATE_SESSION takes additional parameters to
d3e2ba59
JD
193 * support the live reading capability.
194 */
195static int relayd_create_session_2_4(struct lttcomm_relayd_sock *rsock,
fb9a95c4
JG
196 const char *session_name, const char *hostname,
197 int session_live_timer, unsigned int snapshot)
d3e2ba59
JD
198{
199 int ret;
200 struct lttcomm_relayd_create_session_2_4 msg;
201
3a13ffd5
MD
202 if (lttng_strncpy(msg.session_name, session_name,
203 sizeof(msg.session_name))) {
246777db
MD
204 ret = -1;
205 goto error;
206 }
3a13ffd5 207 if (lttng_strncpy(msg.hostname, hostname, sizeof(msg.hostname))) {
246777db
MD
208 ret = -1;
209 goto error;
210 }
d3e2ba59 211 msg.live_timer = htobe32(session_live_timer);
7d2f7452 212 msg.snapshot = htobe32(snapshot);
d3e2ba59
JD
213
214 /* Send command */
215 ret = send_command(rsock, RELAYD_CREATE_SESSION, &msg, sizeof(msg), 0);
216 if (ret < 0) {
217 goto error;
218 }
219
220error:
221 return ret;
222}
223
224/*
225 * RELAYD_CREATE_SESSION from 2.1 to 2.3.
226 */
42e9a27b 227static int relayd_create_session_2_1(struct lttcomm_relayd_sock *rsock)
d3e2ba59
JD
228{
229 int ret;
230
231 /* Send command */
232 ret = send_command(rsock, RELAYD_CREATE_SESSION, NULL, 0, 0);
233 if (ret < 0) {
234 goto error;
235 }
236
237error:
238 return ret;
239}
240
c5b6f4f0
DG
241/*
242 * Send a RELAYD_CREATE_SESSION command to the relayd with the given socket and
243 * set session_id of the relayd if we have a successful reply from the relayd.
244 *
20275fe8
DG
245 * On success, return 0 else a negative value which is either an errno error or
246 * a lttng error code from the relayd.
c5b6f4f0 247 */
fb9a95c4
JG
248int relayd_create_session(struct lttcomm_relayd_sock *rsock,
249 uint64_t *relayd_session_id,
250 const char *session_name, const char *hostname,
251 int session_live_timer,
658f12fa 252 unsigned int snapshot, uint64_t sessiond_session_id,
f39bd140 253 const lttng_uuid sessiond_uuid,
db1da059
JG
254 const uint64_t *current_chunk_id,
255 time_t creation_time)
c5b6f4f0
DG
256{
257 int ret;
258 struct lttcomm_relayd_status_session reply;
259
6151a90f 260 assert(rsock);
658f12fa 261 assert(relayd_session_id);
c5b6f4f0
DG
262
263 DBG("Relayd create session");
264
f86f6389
JR
265 if (rsock->minor < 4) {
266 /* From 2.1 to 2.3 */
267 ret = relayd_create_session_2_1(rsock);
268 } else if (rsock->minor >= 4 && rsock->minor < 11) {
269 /* From 2.4 to 2.10 */
270 ret = relayd_create_session_2_4(rsock, session_name,
271 hostname, session_live_timer, snapshot);
272 } else {
273 /* From 2.11 to ... */
274 ret = relayd_create_session_2_11(rsock, session_name,
658f12fa 275 hostname, session_live_timer, snapshot,
f39bd140 276 sessiond_session_id, sessiond_uuid,
db1da059 277 current_chunk_id, creation_time);
d3e2ba59
JD
278 }
279
c5b6f4f0
DG
280 if (ret < 0) {
281 goto error;
282 }
283
20275fe8 284 /* Receive response */
6151a90f 285 ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
c5b6f4f0
DG
286 if (ret < 0) {
287 goto error;
288 }
289
290 reply.session_id = be64toh(reply.session_id);
291 reply.ret_code = be32toh(reply.ret_code);
292
293 /* Return session id or negative ret code. */
294 if (reply.ret_code != LTTNG_OK) {
bb63afd9
DG
295 ret = -1;
296 ERR("Relayd create session replied error %d", reply.ret_code);
c5b6f4f0
DG
297 goto error;
298 } else {
299 ret = 0;
658f12fa 300 *relayd_session_id = reply.session_id;
c5b6f4f0
DG
301 }
302
303 DBG("Relayd session created with id %" PRIu64, reply.session_id);
304
305error:
306 return ret;
307}
308
2f21a469
JR
309static int relayd_add_stream_2_1(struct lttcomm_relayd_sock *rsock,
310 const char *channel_name, const char *pathname)
311{
312 int ret;
313 struct lttcomm_relayd_add_stream msg;
314
315 memset(&msg, 0, sizeof(msg));
316 if (lttng_strncpy(msg.channel_name, channel_name,
317 sizeof(msg.channel_name))) {
318 ret = -1;
319 goto error;
320 }
321
322 if (lttng_strncpy(msg.pathname, pathname,
323 sizeof(msg.pathname))) {
324 ret = -1;
325 goto error;
326 }
327
328 /* Send command */
329 ret = send_command(rsock, RELAYD_ADD_STREAM, (void *) &msg, sizeof(msg), 0);
330 if (ret < 0) {
331 ret = -1;
332 goto error;
333 }
334 ret = 0;
335error:
336 return ret;
337}
338
339static int relayd_add_stream_2_2(struct lttcomm_relayd_sock *rsock,
340 const char *channel_name, const char *pathname,
341 uint64_t tracefile_size, uint64_t tracefile_count)
342{
343 int ret;
344 struct lttcomm_relayd_add_stream_2_2 msg;
345
346 memset(&msg, 0, sizeof(msg));
347 /* Compat with relayd 2.2 to 2.10 */
348 if (lttng_strncpy(msg.channel_name, channel_name,
349 sizeof(msg.channel_name))) {
350 ret = -1;
351 goto error;
352 }
353 if (lttng_strncpy(msg.pathname, pathname,
354 sizeof(msg.pathname))) {
355 ret = -1;
356 goto error;
357 }
358 msg.tracefile_size = htobe64(tracefile_size);
359 msg.tracefile_count = htobe64(tracefile_count);
360
361 /* Send command */
362 ret = send_command(rsock, RELAYD_ADD_STREAM, (void *) &msg, sizeof(msg), 0);
363 if (ret < 0) {
364 goto error;
365 }
366 ret = 0;
367error:
368 return ret;
369}
370
371static int relayd_add_stream_2_11(struct lttcomm_relayd_sock *rsock,
372 const char *channel_name, const char *pathname,
b00e554e
JG
373 uint64_t tracefile_size, uint64_t tracefile_count,
374 uint64_t trace_archive_id)
2f21a469
JR
375{
376 int ret;
377 struct lttcomm_relayd_add_stream_2_11 *msg = NULL;
378 size_t channel_name_len;
379 size_t pathname_len;
380 size_t msg_length;
381
382 /* The two names are sent with a '\0' delimiter between them. */
383 channel_name_len = strlen(channel_name) + 1;
384 pathname_len = strlen(pathname) + 1;
385
386 msg_length = sizeof(*msg) + channel_name_len + pathname_len;
387 msg = zmalloc(msg_length);
388 if (!msg) {
389 PERROR("zmalloc add_stream_2_11 command message");
390 ret = -1;
391 goto error;
392 }
393
394 assert(channel_name_len <= UINT32_MAX);
395 msg->channel_name_len = htobe32(channel_name_len);
396
397 assert(pathname_len <= UINT32_MAX);
398 msg->pathname_len = htobe32(pathname_len);
399
400 if (lttng_strncpy(msg->names, channel_name, channel_name_len)) {
401 ret = -1;
402 goto error;
403 }
404 if (lttng_strncpy(msg->names + channel_name_len, pathname, pathname_len)) {
405 ret = -1;
406 goto error;
407 }
408
409 msg->tracefile_size = htobe64(tracefile_size);
410 msg->tracefile_count = htobe64(tracefile_count);
348a81dc 411 msg->trace_chunk_id = htobe64(trace_archive_id);
2f21a469
JR
412
413 /* Send command */
414 ret = send_command(rsock, RELAYD_ADD_STREAM, (void *) msg, msg_length, 0);
415 if (ret < 0) {
416 goto error;
417 }
418 ret = 0;
419error:
420 free(msg);
421 return ret;
422}
423
00e2e675
DG
424/*
425 * Add stream on the relayd and assign stream handle to the stream_id argument.
426 *
427 * On success return 0 else return ret_code negative value.
428 */
6151a90f 429int relayd_add_stream(struct lttcomm_relayd_sock *rsock, const char *channel_name,
0f907de1 430 const char *pathname, uint64_t *stream_id,
0b50e4b3 431 uint64_t tracefile_size, uint64_t tracefile_count,
d2956687 432 struct lttng_trace_chunk *trace_chunk)
00e2e675
DG
433{
434 int ret;
00e2e675
DG
435 struct lttcomm_relayd_status_stream reply;
436
437 /* Code flow error. Safety net. */
6151a90f 438 assert(rsock);
00e2e675
DG
439 assert(channel_name);
440 assert(pathname);
441
442 DBG("Relayd adding stream for channel name %s", channel_name);
443
0f907de1
JD
444 /* Compat with relayd 2.1 */
445 if (rsock->minor == 1) {
2f21a469 446 /* For 2.1 */
d2956687 447 assert(!trace_chunk);
2f21a469
JR
448 ret = relayd_add_stream_2_1(rsock, channel_name, pathname);
449
450 } else if (rsock->minor > 1 && rsock->minor < 11) {
451 /* From 2.2 to 2.10 */
d2956687 452 assert(!trace_chunk);
2f21a469
JR
453 ret = relayd_add_stream_2_2(rsock, channel_name, pathname,
454 tracefile_size, tracefile_count);
0f907de1 455 } else {
d2956687
JG
456 enum lttng_trace_chunk_status chunk_status;
457 uint64_t chunk_id;
458
459 assert(trace_chunk);
460 chunk_status = lttng_trace_chunk_get_id(trace_chunk,
461 &chunk_id);
462 assert(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
463
2f21a469
JR
464 /* From 2.11 to ...*/
465 ret = relayd_add_stream_2_11(rsock, channel_name, pathname,
b00e554e 466 tracefile_size, tracefile_count,
d2956687 467 chunk_id);
2f21a469 468 }
0f907de1 469
2f21a469
JR
470 if (ret) {
471 ret = -1;
472 goto error;
00e2e675
DG
473 }
474
633d0084 475 /* Waiting for reply */
6151a90f 476 ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
00e2e675
DG
477 if (ret < 0) {
478 goto error;
479 }
480
481 /* Back to host bytes order. */
482 reply.handle = be64toh(reply.handle);
483 reply.ret_code = be32toh(reply.ret_code);
484
485 /* Return session id or negative ret code. */
f73fabfd 486 if (reply.ret_code != LTTNG_OK) {
bb63afd9
DG
487 ret = -1;
488 ERR("Relayd add stream replied error %d", reply.ret_code);
00e2e675
DG
489 } else {
490 /* Success */
491 ret = 0;
492 *stream_id = reply.handle;
493 }
494
77c7c900 495 DBG("Relayd stream added successfully with handle %" PRIu64,
2f21a469 496 reply.handle);
00e2e675
DG
497
498error:
499 return ret;
500}
501
a4baae1b
JD
502/*
503 * Inform the relay that all the streams for the current channel has been sent.
504 *
505 * On success return 0 else return ret_code negative value.
506 */
507int relayd_streams_sent(struct lttcomm_relayd_sock *rsock)
508{
509 int ret;
510 struct lttcomm_relayd_generic_reply reply;
511
512 /* Code flow error. Safety net. */
513 assert(rsock);
514
515 DBG("Relayd sending streams sent.");
516
517 /* This feature was introduced in 2.4, ignore it for earlier versions. */
518 if (rsock->minor < 4) {
519 ret = 0;
520 goto end;
521 }
522
523 /* Send command */
524 ret = send_command(rsock, RELAYD_STREAMS_SENT, NULL, 0, 0);
525 if (ret < 0) {
526 goto error;
527 }
528
529 /* Waiting for reply */
530 ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
531 if (ret < 0) {
532 goto error;
533 }
534
535 /* Back to host bytes order. */
536 reply.ret_code = be32toh(reply.ret_code);
537
538 /* Return session id or negative ret code. */
539 if (reply.ret_code != LTTNG_OK) {
540 ret = -1;
541 ERR("Relayd streams sent replied error %d", reply.ret_code);
542 goto error;
543 } else {
544 /* Success */
545 ret = 0;
546 }
547
548 DBG("Relayd streams sent success");
549
550error:
551end:
552 return ret;
553}
554
00e2e675
DG
555/*
556 * Check version numbers on the relayd.
d4519fa3
JD
557 * If major versions are compatible, we assign minor_to_use to the
558 * minor version of the procotol we are going to use for this session.
00e2e675 559 *
67d5aa28
JD
560 * Return 0 if the two daemons are compatible, LTTNG_ERR_RELAYD_VERSION_FAIL
561 * otherwise, or a negative value on network errors.
00e2e675 562 */
6151a90f 563int relayd_version_check(struct lttcomm_relayd_sock *rsock)
00e2e675
DG
564{
565 int ret;
092b6259 566 struct lttcomm_relayd_version msg;
00e2e675
DG
567
568 /* Code flow error. Safety net. */
6151a90f 569 assert(rsock);
00e2e675 570
6151a90f
JD
571 DBG("Relayd version check for major.minor %u.%u", rsock->major,
572 rsock->minor);
00e2e675 573
53efb85a 574 memset(&msg, 0, sizeof(msg));
092b6259 575 /* Prepare network byte order before transmission. */
6151a90f
JD
576 msg.major = htobe32(rsock->major);
577 msg.minor = htobe32(rsock->minor);
092b6259 578
00e2e675 579 /* Send command */
6151a90f 580 ret = send_command(rsock, RELAYD_VERSION, (void *) &msg, sizeof(msg), 0);
00e2e675
DG
581 if (ret < 0) {
582 goto error;
583 }
584
20275fe8 585 /* Receive response */
6151a90f 586 ret = recv_reply(rsock, (void *) &msg, sizeof(msg));
00e2e675
DG
587 if (ret < 0) {
588 goto error;
589 }
590
591 /* Set back to host bytes order */
092b6259
DG
592 msg.major = be32toh(msg.major);
593 msg.minor = be32toh(msg.minor);
594
595 /*
596 * Only validate the major version. If the other side is higher,
597 * communication is not possible. Only major version equal can talk to each
598 * other. If the minor version differs, the lowest version is used by both
599 * sides.
092b6259 600 */
6151a90f 601 if (msg.major != rsock->major) {
d4519fa3 602 /* Not compatible */
67d5aa28 603 ret = LTTNG_ERR_RELAYD_VERSION_FAIL;
d4519fa3 604 DBG2("Relayd version is NOT compatible. Relayd version %u != %u (us)",
6151a90f 605 msg.major, rsock->major);
092b6259 606 goto error;
00e2e675
DG
607 }
608
092b6259 609 /*
6151a90f
JD
610 * If the relayd's minor version is higher, it will adapt to our version so
611 * we can continue to use the latest relayd communication data structure.
612 * If the received minor version is higher, the relayd should adapt to us.
092b6259 613 */
6151a90f
JD
614 if (rsock->minor > msg.minor) {
615 rsock->minor = msg.minor;
d4519fa3 616 }
092b6259 617
d4519fa3
JD
618 /* Version number compatible */
619 DBG2("Relayd version is compatible, using protocol version %u.%u",
6151a90f 620 rsock->major, rsock->minor);
d4519fa3 621 ret = 0;
00e2e675
DG
622
623error:
624 return ret;
625}
626
00e2e675
DG
627/*
628 * Add stream on the relayd and assign stream handle to the stream_id argument.
629 *
630 * On success return 0 else return ret_code negative value.
631 */
6151a90f 632int relayd_send_metadata(struct lttcomm_relayd_sock *rsock, size_t len)
00e2e675
DG
633{
634 int ret;
635
636 /* Code flow error. Safety net. */
6151a90f 637 assert(rsock);
00e2e675 638
77c7c900 639 DBG("Relayd sending metadata of size %zu", len);
00e2e675
DG
640
641 /* Send command */
6151a90f 642 ret = send_command(rsock, RELAYD_SEND_METADATA, NULL, len, 0);
00e2e675
DG
643 if (ret < 0) {
644 goto error;
645 }
646
647 DBG2("Relayd metadata added successfully");
648
649 /*
650 * After that call, the metadata data MUST be sent to the relayd so the
651 * receive size on the other end matches the len of the metadata packet
633d0084 652 * header. This is why we don't wait for a reply here.
00e2e675
DG
653 */
654
655error:
656 return ret;
657}
658
659/*
6151a90f 660 * Connect to relay daemon with an allocated lttcomm_relayd_sock.
00e2e675 661 */
6151a90f 662int relayd_connect(struct lttcomm_relayd_sock *rsock)
00e2e675
DG
663{
664 /* Code flow error. Safety net. */
6151a90f 665 assert(rsock);
00e2e675 666
f96e4545
MD
667 if (!rsock->sock.ops) {
668 /*
669 * Attempting a connect on a non-initialized socket.
670 */
671 return -ECONNRESET;
672 }
673
00e2e675
DG
674 DBG3("Relayd connect ...");
675
6151a90f 676 return rsock->sock.ops->connect(&rsock->sock);
00e2e675
DG
677}
678
679/*
6151a90f 680 * Close relayd socket with an allocated lttcomm_relayd_sock.
ffe60014
DG
681 *
682 * If no socket operations are found, simply return 0 meaning that everything
683 * is fine. Without operations, the socket can not possibly be opened or used.
684 * This is possible if the socket was allocated but not created. However, the
685 * caller could simply use it to store a valid file descriptor for instance
686 * passed over a Unix socket and call this to cleanup but still without a valid
687 * ops pointer.
688 *
689 * Return the close returned value. On error, a negative value is usually
690 * returned back from close(2).
00e2e675 691 */
6151a90f 692int relayd_close(struct lttcomm_relayd_sock *rsock)
00e2e675 693{
ffe60014
DG
694 int ret;
695
00e2e675 696 /* Code flow error. Safety net. */
6151a90f 697 assert(rsock);
00e2e675 698
ffe60014 699 /* An invalid fd is fine, return success. */
6151a90f 700 if (rsock->sock.fd < 0) {
ffe60014
DG
701 ret = 0;
702 goto end;
703 }
704
6151a90f 705 DBG3("Relayd closing socket %d", rsock->sock.fd);
00e2e675 706
6151a90f
JD
707 if (rsock->sock.ops) {
708 ret = rsock->sock.ops->close(&rsock->sock);
ffe60014
DG
709 } else {
710 /* Default call if no specific ops found. */
6151a90f 711 ret = close(rsock->sock.fd);
ffe60014
DG
712 if (ret < 0) {
713 PERROR("relayd_close default close");
714 }
715 }
f96e4545 716 rsock->sock.fd = -1;
ffe60014
DG
717
718end:
719 return ret;
00e2e675
DG
720}
721
722/*
723 * Send data header structure to the relayd.
724 */
6151a90f 725int relayd_send_data_hdr(struct lttcomm_relayd_sock *rsock,
00e2e675
DG
726 struct lttcomm_relayd_data_hdr *hdr, size_t size)
727{
728 int ret;
729
730 /* Code flow error. Safety net. */
6151a90f 731 assert(rsock);
00e2e675
DG
732 assert(hdr);
733
f96e4545
MD
734 if (rsock->sock.fd < 0) {
735 return -ECONNRESET;
736 }
737
8fd623e0 738 DBG3("Relayd sending data header of size %zu", size);
00e2e675
DG
739
740 /* Again, safety net */
741 if (size == 0) {
742 size = sizeof(struct lttcomm_relayd_data_hdr);
743 }
744
745 /* Only send data header. */
6151a90f 746 ret = rsock->sock.ops->sendmsg(&rsock->sock, hdr, size, 0);
00e2e675 747 if (ret < 0) {
8994307f 748 ret = -errno;
00e2e675
DG
749 goto error;
750 }
751
752 /*
753 * The data MUST be sent right after that command for the receive on the
754 * other end to match the size in the header.
755 */
756
757error:
758 return ret;
759}
173af62f
DG
760
761/*
762 * Send close stream command to the relayd.
763 */
6151a90f 764int relayd_send_close_stream(struct lttcomm_relayd_sock *rsock, uint64_t stream_id,
173af62f
DG
765 uint64_t last_net_seq_num)
766{
767 int ret;
768 struct lttcomm_relayd_close_stream msg;
769 struct lttcomm_relayd_generic_reply reply;
770
771 /* Code flow error. Safety net. */
6151a90f 772 assert(rsock);
173af62f 773
77c7c900 774 DBG("Relayd closing stream id %" PRIu64, stream_id);
173af62f 775
53efb85a 776 memset(&msg, 0, sizeof(msg));
173af62f
DG
777 msg.stream_id = htobe64(stream_id);
778 msg.last_net_seq_num = htobe64(last_net_seq_num);
779
780 /* Send command */
6151a90f 781 ret = send_command(rsock, RELAYD_CLOSE_STREAM, (void *) &msg, sizeof(msg), 0);
173af62f
DG
782 if (ret < 0) {
783 goto error;
784 }
785
20275fe8 786 /* Receive response */
6151a90f 787 ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
173af62f
DG
788 if (ret < 0) {
789 goto error;
790 }
791
792 reply.ret_code = be32toh(reply.ret_code);
793
794 /* Return session id or negative ret code. */
f73fabfd 795 if (reply.ret_code != LTTNG_OK) {
bb63afd9
DG
796 ret = -1;
797 ERR("Relayd close stream replied error %d", reply.ret_code);
173af62f
DG
798 } else {
799 /* Success */
800 ret = 0;
801 }
802
77c7c900 803 DBG("Relayd close stream id %" PRIu64 " successfully", stream_id);
173af62f
DG
804
805error:
806 return ret;
807}
c8f59ee5
DG
808
809/*
810 * Check for data availability for a given stream id.
811 *
6d805429 812 * Return 0 if NOT pending, 1 if so and a negative value on error.
c8f59ee5 813 */
6151a90f 814int relayd_data_pending(struct lttcomm_relayd_sock *rsock, uint64_t stream_id,
c8f59ee5
DG
815 uint64_t last_net_seq_num)
816{
817 int ret;
6d805429 818 struct lttcomm_relayd_data_pending msg;
c8f59ee5
DG
819 struct lttcomm_relayd_generic_reply reply;
820
821 /* Code flow error. Safety net. */
6151a90f 822 assert(rsock);
c8f59ee5 823
6d805429 824 DBG("Relayd data pending for stream id %" PRIu64, stream_id);
c8f59ee5 825
53efb85a 826 memset(&msg, 0, sizeof(msg));
c8f59ee5
DG
827 msg.stream_id = htobe64(stream_id);
828 msg.last_net_seq_num = htobe64(last_net_seq_num);
829
830 /* Send command */
6151a90f 831 ret = send_command(rsock, RELAYD_DATA_PENDING, (void *) &msg,
c8f59ee5
DG
832 sizeof(msg), 0);
833 if (ret < 0) {
834 goto error;
835 }
836
20275fe8 837 /* Receive response */
6151a90f 838 ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
c8f59ee5
DG
839 if (ret < 0) {
840 goto error;
841 }
842
843 reply.ret_code = be32toh(reply.ret_code);
844
845 /* Return session id or negative ret code. */
846 if (reply.ret_code >= LTTNG_OK) {
bb63afd9 847 ERR("Relayd data pending replied error %d", reply.ret_code);
c8f59ee5
DG
848 }
849
850 /* At this point, the ret code is either 1 or 0 */
851 ret = reply.ret_code;
852
6d805429 853 DBG("Relayd data is %s pending for stream id %" PRIu64,
9dd26bb9 854 ret == 1 ? "" : "NOT", stream_id);
c8f59ee5
DG
855
856error:
857 return ret;
858}
859
860/*
861 * Check on the relayd side for a quiescent state on the control socket.
862 */
6151a90f 863int relayd_quiescent_control(struct lttcomm_relayd_sock *rsock,
ad7051c0 864 uint64_t metadata_stream_id)
c8f59ee5
DG
865{
866 int ret;
ad7051c0 867 struct lttcomm_relayd_quiescent_control msg;
c8f59ee5
DG
868 struct lttcomm_relayd_generic_reply reply;
869
870 /* Code flow error. Safety net. */
6151a90f 871 assert(rsock);
c8f59ee5
DG
872
873 DBG("Relayd checking quiescent control state");
874
53efb85a 875 memset(&msg, 0, sizeof(msg));
ad7051c0
DG
876 msg.stream_id = htobe64(metadata_stream_id);
877
c8f59ee5 878 /* Send command */
6151a90f 879 ret = send_command(rsock, RELAYD_QUIESCENT_CONTROL, &msg, sizeof(msg), 0);
c8f59ee5
DG
880 if (ret < 0) {
881 goto error;
882 }
883
20275fe8 884 /* Receive response */
6151a90f 885 ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
c8f59ee5
DG
886 if (ret < 0) {
887 goto error;
888 }
889
890 reply.ret_code = be32toh(reply.ret_code);
891
892 /* Return session id or negative ret code. */
893 if (reply.ret_code != LTTNG_OK) {
bb63afd9
DG
894 ret = -1;
895 ERR("Relayd quiescent control replied error %d", reply.ret_code);
c8f59ee5
DG
896 goto error;
897 }
898
899 /* Control socket is quiescent */
6d805429 900 return 0;
c8f59ee5
DG
901
902error:
903 return ret;
904}
f7079f67
DG
905
906/*
907 * Begin a data pending command for a specific session id.
908 */
6151a90f 909int relayd_begin_data_pending(struct lttcomm_relayd_sock *rsock, uint64_t id)
f7079f67
DG
910{
911 int ret;
912 struct lttcomm_relayd_begin_data_pending msg;
913 struct lttcomm_relayd_generic_reply reply;
914
915 /* Code flow error. Safety net. */
6151a90f 916 assert(rsock);
f7079f67
DG
917
918 DBG("Relayd begin data pending");
919
53efb85a 920 memset(&msg, 0, sizeof(msg));
f7079f67
DG
921 msg.session_id = htobe64(id);
922
923 /* Send command */
6151a90f 924 ret = send_command(rsock, RELAYD_BEGIN_DATA_PENDING, &msg, sizeof(msg), 0);
f7079f67
DG
925 if (ret < 0) {
926 goto error;
927 }
928
20275fe8 929 /* Receive response */
6151a90f 930 ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
f7079f67
DG
931 if (ret < 0) {
932 goto error;
933 }
934
935 reply.ret_code = be32toh(reply.ret_code);
936
937 /* Return session id or negative ret code. */
938 if (reply.ret_code != LTTNG_OK) {
bb63afd9
DG
939 ret = -1;
940 ERR("Relayd begin data pending replied error %d", reply.ret_code);
f7079f67
DG
941 goto error;
942 }
943
944 return 0;
945
946error:
947 return ret;
948}
949
950/*
951 * End a data pending command for a specific session id.
952 *
953 * Return 0 on success and set is_data_inflight to 0 if no data is being
954 * streamed or 1 if it is the case.
955 */
6151a90f 956int relayd_end_data_pending(struct lttcomm_relayd_sock *rsock, uint64_t id,
f7079f67
DG
957 unsigned int *is_data_inflight)
958{
af6c30b5 959 int ret, recv_ret;
f7079f67
DG
960 struct lttcomm_relayd_end_data_pending msg;
961 struct lttcomm_relayd_generic_reply reply;
962
963 /* Code flow error. Safety net. */
6151a90f 964 assert(rsock);
f7079f67
DG
965
966 DBG("Relayd end data pending");
967
53efb85a 968 memset(&msg, 0, sizeof(msg));
f7079f67
DG
969 msg.session_id = htobe64(id);
970
971 /* Send command */
6151a90f 972 ret = send_command(rsock, RELAYD_END_DATA_PENDING, &msg, sizeof(msg), 0);
f7079f67
DG
973 if (ret < 0) {
974 goto error;
975 }
976
20275fe8 977 /* Receive response */
6151a90f 978 ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
f7079f67
DG
979 if (ret < 0) {
980 goto error;
981 }
982
af6c30b5
DG
983 recv_ret = be32toh(reply.ret_code);
984 if (recv_ret < 0) {
985 ret = recv_ret;
f7079f67
DG
986 goto error;
987 }
988
af6c30b5 989 *is_data_inflight = recv_ret;
f7079f67 990
af6c30b5 991 DBG("Relayd end data pending is data inflight: %d", recv_ret);
f7079f67
DG
992
993 return 0;
994
995error:
996 return ret;
997}
1c20f0e2
JD
998
999/*
1000 * Send index to the relayd.
1001 */
1002int relayd_send_index(struct lttcomm_relayd_sock *rsock,
50adc264 1003 struct ctf_packet_index *index, uint64_t relay_stream_id,
1c20f0e2
JD
1004 uint64_t net_seq_num)
1005{
1006 int ret;
1007 struct lttcomm_relayd_index msg;
1008 struct lttcomm_relayd_generic_reply reply;
1009
1010 /* Code flow error. Safety net. */
1011 assert(rsock);
1012
1013 if (rsock->minor < 4) {
1014 DBG("Not sending indexes before protocol 2.4");
1015 ret = 0;
1016 goto error;
1017 }
1018
1019 DBG("Relayd sending index for stream ID %" PRIu64, relay_stream_id);
1020
53efb85a 1021 memset(&msg, 0, sizeof(msg));
1c20f0e2
JD
1022 msg.relay_stream_id = htobe64(relay_stream_id);
1023 msg.net_seq_num = htobe64(net_seq_num);
1024
1025 /* The index is already in big endian. */
1026 msg.packet_size = index->packet_size;
1027 msg.content_size = index->content_size;
1028 msg.timestamp_begin = index->timestamp_begin;
1029 msg.timestamp_end = index->timestamp_end;
1030 msg.events_discarded = index->events_discarded;
1031 msg.stream_id = index->stream_id;
1032
234cd636
JD
1033 if (rsock->minor >= 8) {
1034 msg.stream_instance_id = index->stream_instance_id;
1035 msg.packet_seq_num = index->packet_seq_num;
1036 }
1037
1c20f0e2 1038 /* Send command */
f8f3885c
MD
1039 ret = send_command(rsock, RELAYD_SEND_INDEX, &msg,
1040 lttcomm_relayd_index_len(lttng_to_index_major(rsock->major,
1041 rsock->minor),
1042 lttng_to_index_minor(rsock->major, rsock->minor)),
1043 0);
1c20f0e2
JD
1044 if (ret < 0) {
1045 goto error;
1046 }
1047
1048 /* Receive response */
1049 ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
1050 if (ret < 0) {
1051 goto error;
1052 }
1053
1054 reply.ret_code = be32toh(reply.ret_code);
1055
1056 /* Return session id or negative ret code. */
1057 if (reply.ret_code != LTTNG_OK) {
1058 ret = -1;
1059 ERR("Relayd send index replied error %d", reply.ret_code);
1060 } else {
1061 /* Success */
1062 ret = 0;
1063 }
1064
1065error:
1066 return ret;
1067}
93ec662e
JD
1068
1069/*
1070 * Ask the relay to reset the metadata trace file (regeneration).
1071 */
1072int relayd_reset_metadata(struct lttcomm_relayd_sock *rsock,
1073 uint64_t stream_id, uint64_t version)
1074{
1075 int ret;
1076 struct lttcomm_relayd_reset_metadata msg;
1077 struct lttcomm_relayd_generic_reply reply;
1078
1079 /* Code flow error. Safety net. */
1080 assert(rsock);
1081
1082 /* Should have been prevented by the sessiond. */
1083 if (rsock->minor < 8) {
1084 ERR("Metadata regeneration unsupported before 2.8");
1085 ret = -1;
1086 goto error;
1087 }
1088
1089 DBG("Relayd reset metadata stream id %" PRIu64, stream_id);
1090
1091 memset(&msg, 0, sizeof(msg));
1092 msg.stream_id = htobe64(stream_id);
1093 msg.version = htobe64(version);
1094
1095 /* Send command */
1096 ret = send_command(rsock, RELAYD_RESET_METADATA, (void *) &msg, sizeof(msg), 0);
1097 if (ret < 0) {
1098 goto error;
1099 }
1100
1101 /* Receive response */
1102 ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
1103 if (ret < 0) {
1104 goto error;
1105 }
1106
1107 reply.ret_code = be32toh(reply.ret_code);
1108
1109 /* Return session id or negative ret code. */
1110 if (reply.ret_code != LTTNG_OK) {
1111 ret = -1;
1112 ERR("Relayd reset metadata replied error %d", reply.ret_code);
1113 } else {
1114 /* Success */
1115 ret = 0;
1116 }
1117
1118 DBG("Relayd reset metadata stream id %" PRIu64 " successfully", stream_id);
1119
1120error:
1121 return ret;
1122}
a1ae2ea5 1123
d73bf3d7 1124int relayd_rotate_stream(struct lttcomm_relayd_sock *rsock, uint64_t stream_id,
d2956687 1125 uint64_t new_chunk_id, uint64_t seq_num)
d73bf3d7
JD
1126{
1127 int ret;
1128 struct lttcomm_relayd_rotate_stream *msg = NULL;
1129 struct lttcomm_relayd_generic_reply reply;
1130 size_t len;
1131 int msg_len;
d2956687
JG
1132 /* FIXME */
1133 char *new_pathname = NULL;
d73bf3d7
JD
1134
1135 /* Code flow error. Safety net. */
1136 assert(rsock);
1137
1138 DBG("Sending rotate stream id %" PRIu64 " command to relayd", stream_id);
1139
1140 /* Account for the trailing NULL. */
27283937 1141 len = lttng_strnlen(new_pathname, LTTNG_PATH_MAX) + 1;
d73bf3d7
JD
1142 if (len > LTTNG_PATH_MAX) {
1143 ERR("Path used in relayd rotate stream command exceeds the maximal allowed length");
1144 ret = -1;
1145 goto error;
1146 }
1147
1148 msg_len = offsetof(struct lttcomm_relayd_rotate_stream, new_pathname) + len;
1149 msg = zmalloc(msg_len);
1150 if (!msg) {
1151 PERROR("Failed to allocate relayd rotate stream command of %d bytes",
1152 msg_len);
1153 ret = -1;
1154 goto error;
1155 }
1156
1157 if (lttng_strncpy(msg->new_pathname, new_pathname, len)) {
1158 ret = -1;
1159 ERR("Failed to copy relayd rotate stream command's new path name");
1160 goto error;
1161 }
1162
1163 msg->pathname_length = htobe32(len);
1164 msg->stream_id = htobe64(stream_id);
1165 msg->new_chunk_id = htobe64(new_chunk_id);
1166 /*
1167 * The seq_num is invalid for metadata streams, but it is ignored on
1168 * the relay.
1169 */
1170 msg->rotate_at_seq_num = htobe64(seq_num);
1171
1172 /* Send command. */
1173 ret = send_command(rsock, RELAYD_ROTATE_STREAM, (void *) msg, msg_len, 0);
1174 if (ret < 0) {
1175 ERR("Send rotate command");
1176 goto error;
1177 }
1178
1179 /* Receive response. */
1180 ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
1181 if (ret < 0) {
1182 ERR("Receive rotate reply");
1183 goto error;
1184 }
1185
1186 reply.ret_code = be32toh(reply.ret_code);
1187
1188 /* Return session id or negative ret code. */
1189 if (reply.ret_code != LTTNG_OK) {
1190 ret = -1;
1191 ERR("Relayd rotate stream replied error %d", reply.ret_code);
1192 } else {
1193 /* Success. */
1194 ret = 0;
1195 DBG("Relayd rotated stream id %" PRIu64 " successfully", stream_id);
1196 }
1197
1198error:
1199 free(msg);
1200 return ret;
1201}
e5add6d0
JG
1202
1203int relayd_create_trace_chunk(struct lttcomm_relayd_sock *sock,
1204 struct lttng_trace_chunk *chunk)
1205{
1206 int ret = 0;
1207 enum lttng_trace_chunk_status status;
1208 struct lttcomm_relayd_create_trace_chunk msg = {};
1209 struct lttcomm_relayd_generic_reply reply = {};
1210 struct lttng_dynamic_buffer payload;
1211 uint64_t chunk_id;
1212 time_t creation_timestamp;
1213 const char *chunk_name;
1214 size_t chunk_name_length;
1215 bool overriden_name;
1216
1217 lttng_dynamic_buffer_init(&payload);
1218
1219 status = lttng_trace_chunk_get_id(chunk, &chunk_id);
1220 if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
1221 ret = -1;
1222 goto end;
1223 }
1224
1225 status = lttng_trace_chunk_get_creation_timestamp(
1226 chunk, &creation_timestamp);
1227 if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
1228 ret = -1;
1229 goto end;
1230 }
1231
1232 status = lttng_trace_chunk_get_name(
1233 chunk, &chunk_name, &overriden_name);
1234 if (status != LTTNG_TRACE_CHUNK_STATUS_OK &&
1235 status != LTTNG_TRACE_CHUNK_STATUS_NONE) {
1236 ret = -1;
1237 goto end;
1238 }
1239
1240 chunk_name_length = overriden_name ? (strlen(chunk_name) + 1) : 0;
1241 msg = (typeof(msg)){
1242 .chunk_id = htobe64(chunk_id),
1243 .creation_timestamp = htobe64((uint64_t) creation_timestamp),
1244 .override_name_length = htobe32((uint32_t) chunk_name_length),
1245 };
1246
1247 ret = lttng_dynamic_buffer_append(&payload, &msg, sizeof(msg));
1248 if (ret) {
1249 goto end;
1250 }
1251 if (chunk_name_length) {
1252 ret = lttng_dynamic_buffer_append(
1253 &payload, chunk_name, chunk_name_length);
1254 if (ret) {
1255 goto end;
1256 }
1257 }
1258
bbc4768c
JG
1259 ret = send_command(sock, RELAYD_CREATE_TRACE_CHUNK, payload.data,
1260 payload.size, 0);
e5add6d0
JG
1261 if (ret < 0) {
1262 ERR("Failed to send trace chunk creation command to relay daemon");
1263 goto end;
1264 }
1265
1266 ret = recv_reply(sock, &reply, sizeof(reply));
1267 if (ret < 0) {
1268 ERR("Failed to receive relay daemon trace chunk creation command reply");
1269 goto end;
1270 }
1271
1272 reply.ret_code = be32toh(reply.ret_code);
1273 if (reply.ret_code != LTTNG_OK) {
1274 ret = -1;
1275 ERR("Relayd trace chunk create replied error %d",
1276 reply.ret_code);
1277 } else {
1278 ret = 0;
1279 DBG("Relayd successfully created trace chunk: chunk_id = %" PRIu64,
1280 chunk_id);
1281 }
1282
1283end:
1284 lttng_dynamic_buffer_reset(&payload);
1285 return ret;
1286}
bbc4768c
JG
1287
1288int relayd_close_trace_chunk(struct lttcomm_relayd_sock *sock,
1289 struct lttng_trace_chunk *chunk)
1290{
1291 int ret = 0;
1292 enum lttng_trace_chunk_status status;
1293 struct lttcomm_relayd_close_trace_chunk msg = {};
1294 struct lttcomm_relayd_generic_reply reply = {};
1295 uint64_t chunk_id;
1296 time_t close_timestamp;
1297 LTTNG_OPTIONAL(enum lttng_trace_chunk_command_type) close_command = {};
1298
1299 status = lttng_trace_chunk_get_id(chunk, &chunk_id);
1300 if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
1301 ERR("Failed to get trace chunk id");
1302 ret = -1;
1303 goto end;
1304 }
1305
1306 status = lttng_trace_chunk_get_close_timestamp(chunk, &close_timestamp);
1307 if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
1308 ERR("Failed to get trace chunk close timestamp");
1309 ret = -1;
1310 goto end;
1311 }
1312
1313 status = lttng_trace_chunk_get_close_command(chunk,
1314 &close_command.value);
1315 switch (status) {
1316 case LTTNG_TRACE_CHUNK_STATUS_OK:
1317 close_command.is_set = 1;
1318 break;
1319 case LTTNG_TRACE_CHUNK_STATUS_NONE:
1320 break;
1321 default:
1322 ERR("Failed to get trace chunk close command");
1323 ret = -1;
1324 goto end;
1325 }
1326
1327 msg = (typeof(msg)){
1328 .chunk_id = htobe64(chunk_id),
1329 .close_timestamp = htobe64((uint64_t) close_timestamp),
1330 .close_command = {
1331 .value = htobe32((uint32_t) close_command.value),
1332 .is_set = close_command.is_set,
1333 },
1334 };
1335
1336 ret = send_command(sock, RELAYD_CLOSE_TRACE_CHUNK, &msg, sizeof(msg),
1337 0);
1338 if (ret < 0) {
1339 ERR("Failed to send trace chunk close command to relay daemon");
1340 goto end;
1341 }
1342
1343 ret = recv_reply(sock, &reply, sizeof(reply));
1344 if (ret < 0) {
1345 ERR("Failed to receive relay daemon trace chunk close command reply");
1346 goto end;
1347 }
1348
1349 reply.ret_code = be32toh(reply.ret_code);
1350 if (reply.ret_code != LTTNG_OK) {
1351 ret = -1;
1352 ERR("Relayd trace chunk close replied error %d",
1353 reply.ret_code);
1354 } else {
1355 ret = 0;
1356 DBG("Relayd successfully closed trace chunk: chunk_id = %" PRIu64,
1357 chunk_id);
1358 }
1359end:
1360 return ret;
1361}
This page took 0.104949 seconds and 4 git commands to generate.