Fix: error out on leftover arguments
[lttng-tools.git] / src / bin / lttng / commands / enable_channels.c
CommitLineData
d36b8583
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
d14d33bf
AM
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
d36b8583
DG
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
d14d33bf
AM
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
d36b8583
DG
16 */
17
6c1c0768 18#define _LGPL_SOURCE
d36b8583
DG
19#include <popt.h>
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <sys/stat.h>
24#include <sys/types.h>
25#include <unistd.h>
5a0de755 26#include <inttypes.h>
1cb514ce
MD
27#include <assert.h>
28#include <ctype.h>
d36b8583 29
acc09215
JRJ
30#include <common/sessiond-comm/sessiond-comm.h>
31#include <common/utils.h>
32#include <common/mi-lttng.h>
33
c399183f 34#include "../command.h"
1cb514ce 35#include "../utils.h"
d36b8583 36
42224349 37
d36b8583 38static char *opt_channels;
5edd7e09 39static int opt_kernel;
5440dc42 40static char *opt_session_name;
d36b8583 41static int opt_userspace;
d78d6610 42static struct lttng_channel chan;
a79d84dd 43static char *opt_output;
7972aab2
DG
44static int opt_buffer_uid;
45static int opt_buffer_pid;
46static int opt_buffer_global;
d36b8583 47
acc09215
JRJ
48static struct mi_writer *writer;
49
d36b8583
DG
50enum {
51 OPT_HELP = 1,
7d29a247
DG
52 OPT_DISCARD,
53 OPT_OVERWRITE,
54 OPT_SUBBUF_SIZE,
55 OPT_NUM_SUBBUF,
56 OPT_SWITCH_TIMER,
57 OPT_READ_TIMER,
d36b8583 58 OPT_USERSPACE,
679b4943 59 OPT_LIST_OPTIONS,
1624d5b7
JD
60 OPT_TRACEFILE_SIZE,
61 OPT_TRACEFILE_COUNT,
d36b8583
DG
62};
63
cd80958d
DG
64static struct lttng_handle *handle;
65
a79d84dd
DG
66const char *output_mmap = "mmap";
67const char *output_splice = "splice";
68
d36b8583
DG
69static struct poptOption long_options[] = {
70 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
71 {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
5440dc42 72 {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
d36b8583 73 {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
d78d6610 74 {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
7d29a247
DG
75 {"discard", 0, POPT_ARG_NONE, 0, OPT_DISCARD, 0, 0},
76 {"overwrite", 0, POPT_ARG_NONE, 0, OPT_OVERWRITE, 0, 0},
70d0b120 77 {"subbuf-size", 0, POPT_ARG_STRING, 0, OPT_SUBBUF_SIZE, 0, 0},
1b579521
DG
78 {"num-subbuf", 0, POPT_ARG_INT, 0, OPT_NUM_SUBBUF, 0, 0},
79 {"switch-timer", 0, POPT_ARG_INT, 0, OPT_SWITCH_TIMER, 0, 0},
80 {"read-timer", 0, POPT_ARG_INT, 0, OPT_READ_TIMER, 0, 0},
679b4943 81 {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
a79d84dd 82 {"output", 0, POPT_ARG_STRING, &opt_output, 0, 0, 0},
7972aab2
DG
83 {"buffers-uid", 0, POPT_ARG_VAL, &opt_buffer_uid, 1, 0, 0},
84 {"buffers-pid", 0, POPT_ARG_VAL, &opt_buffer_pid, 1, 0, 0},
85 {"buffers-global", 0, POPT_ARG_VAL, &opt_buffer_global, 1, 0, 0},
1624d5b7
JD
86 {"tracefile-size", 'C', POPT_ARG_INT, 0, OPT_TRACEFILE_SIZE, 0, 0},
87 {"tracefile-count", 'W', POPT_ARG_INT, 0, OPT_TRACEFILE_COUNT, 0, 0},
d36b8583
DG
88 {0, 0, 0, 0, 0, 0, 0}
89};
90
5edd7e09
DG
91/*
92 * Set default attributes depending on those already defined from the command
93 * line.
94 */
95static void set_default_attr(struct lttng_domain *dom)
96{
97 struct lttng_channel_attr default_attr;
98
99 /* Set attributes */
100 lttng_channel_set_default_attr(dom, &default_attr);
101
102 if (chan.attr.overwrite == -1) {
103 chan.attr.overwrite = default_attr.overwrite;
104 }
105 if (chan.attr.subbuf_size == -1) {
106 chan.attr.subbuf_size = default_attr.subbuf_size;
107 }
108 if (chan.attr.num_subbuf == -1) {
109 chan.attr.num_subbuf = default_attr.num_subbuf;
110 }
111 if (chan.attr.switch_timer_interval == -1) {
112 chan.attr.switch_timer_interval = default_attr.switch_timer_interval;
113 }
114 if (chan.attr.read_timer_interval == -1) {
115 chan.attr.read_timer_interval = default_attr.read_timer_interval;
116 }
109be0da 117 if ((int) chan.attr.output == -1) {
5edd7e09
DG
118 chan.attr.output = default_attr.output;
119 }
1624d5b7
JD
120 if (chan.attr.tracefile_count == -1) {
121 chan.attr.tracefile_count = default_attr.tracefile_count;
122 }
123 if (chan.attr.tracefile_size == -1) {
124 chan.attr.tracefile_size = default_attr.tracefile_size;
125 }
5edd7e09
DG
126}
127
d36b8583 128/*
0fdd1e2c 129 * Adding channel using the lttng API.
d36b8583 130 */
cd80958d 131static int enable_channel(char *session_name)
d36b8583 132{
acc09215 133 int ret = CMD_SUCCESS, warn = 0, error = 0, success = 0;
d36b8583 134 char *channel_name;
7d29a247 135 struct lttng_domain dom;
d36b8583 136
441c16a7
MD
137 memset(&dom, 0, sizeof(dom));
138
d78d6610 139 /* Create lttng domain */
7d29a247
DG
140 if (opt_kernel) {
141 dom.type = LTTNG_DOMAIN_KERNEL;
7972aab2 142 dom.buf_type = LTTNG_BUFFER_GLOBAL;
88c5f0d8
DG
143 if (opt_buffer_uid || opt_buffer_pid) {
144 ERR("Buffer type not supported for domain -k");
145 ret = CMD_ERROR;
146 goto error;
147 }
d78d6610 148 } else if (opt_userspace) {
f6a9efaa 149 dom.type = LTTNG_DOMAIN_UST;
8692d4e5
DG
150 if (opt_buffer_pid) {
151 dom.buf_type = LTTNG_BUFFER_PER_PID;
7972aab2 152 } else {
88c5f0d8
DG
153 if (opt_buffer_global) {
154 ERR("Buffer type not supported for domain -u");
155 ret = CMD_ERROR;
156 goto error;
157 }
8692d4e5 158 dom.buf_type = LTTNG_BUFFER_PER_UID;
7972aab2 159 }
0fdd1e2c 160 } else {
3ecec76a
PP
161 /* Checked by the caller. */
162 assert(0);
7d29a247
DG
163 }
164
5edd7e09
DG
165 set_default_attr(&dom);
166
d16dee89
DG
167 if (chan.attr.tracefile_size == 0 && chan.attr.tracefile_count) {
168 ERR("Missing option --tracefile-size. "
169 "A file count without a size won't do anything.");
170 ret = CMD_ERROR;
171 goto error;
172 }
173
1624d5b7
JD
174 if ((chan.attr.tracefile_size > 0) &&
175 (chan.attr.tracefile_size < chan.attr.subbuf_size)) {
de65565a 176 WARN("Tracefile size rounded up from (%" PRIu64 ") to subbuffer size (%" PRIu64 ")",
1624d5b7 177 chan.attr.tracefile_size, chan.attr.subbuf_size);
de65565a 178 chan.attr.tracefile_size = chan.attr.subbuf_size;
1624d5b7
JD
179 }
180
a79d84dd
DG
181 /* Setting channel output */
182 if (opt_output) {
183 if (!strncmp(output_mmap, opt_output, strlen(output_mmap))) {
184 chan.attr.output = LTTNG_EVENT_MMAP;
185 } else if (!strncmp(output_splice, opt_output, strlen(output_splice))) {
186 chan.attr.output = LTTNG_EVENT_SPLICE;
187 } else {
188 ERR("Unknown output type %s. Possible values are: %s, %s\n",
189 opt_output, output_mmap, output_splice);
a79d84dd
DG
190 ret = CMD_ERROR;
191 goto error;
192 }
193 }
194
cd80958d
DG
195 handle = lttng_create_handle(session_name, &dom);
196 if (handle == NULL) {
197 ret = -1;
198 goto error;
199 }
200
acc09215
JRJ
201 /* Mi open channels element */
202 if (lttng_opt_mi) {
203 assert(writer);
204 ret = mi_lttng_channels_open(writer);
205 if (ret) {
206 ret = CMD_ERROR;
207 goto error;
208 }
209 }
210
0fdd1e2c 211 /* Strip channel list (format: chan1,chan2,...) */
d36b8583
DG
212 channel_name = strtok(opt_channels, ",");
213 while (channel_name != NULL) {
1f345e94
PP
214 /* Validate channel name's length */
215 if (strlen(channel_name) >= NAME_MAX) {
216 ERR("Channel name is too long (max. %zu characters)",
217 sizeof(chan.name) - 1);
218 error = 1;
219 goto skip_enable;
220 }
221
222 /* Copy channel name */
223 strcpy(chan.name, channel_name);
0fdd1e2c
DG
224
225 DBG("Enabling channel %s", channel_name);
226
227 ret = lttng_enable_channel(handle, &chan);
228 if (ret < 0) {
acc09215 229 success = 0;
42224349 230 switch (-ret) {
f73fabfd
DG
231 case LTTNG_ERR_KERN_CHAN_EXIST:
232 case LTTNG_ERR_UST_CHAN_EXIST:
b9dfb167 233 case LTTNG_ERR_CHAN_EXIST:
88c5f0d8 234 WARN("Channel %s: %s (session %s)", channel_name,
42224349 235 lttng_strerror(ret), session_name);
acc09215
JRJ
236 warn = 1;
237 break;
1f345e94
PP
238 case LTTNG_ERR_INVALID_CHANNEL_NAME:
239 ERR("Invalid channel name: \"%s\". "
240 "Channel names may not start with '.', and "
241 "may not contain '/'.", channel_name);
242 error = 1;
243 break;
42224349
DG
244 default:
245 ERR("Channel %s: %s (session %s)", channel_name,
246 lttng_strerror(ret), session_name);
acc09215 247 error = 1;
42224349
DG
248 break;
249 }
d36b8583 250 } else {
7885e399 251 MSG("%s channel %s enabled for session %s",
b9dfb167 252 get_domain_str(dom.type), channel_name, session_name);
acc09215
JRJ
253 success = 1;
254 }
255
1f345e94 256skip_enable:
acc09215
JRJ
257 if (lttng_opt_mi) {
258 /* Mi print the channel element and leave it open */
259 ret = mi_lttng_channel(writer, &chan, 1);
260 if (ret) {
261 ret = CMD_ERROR;
262 goto error;
263 }
264
265 /* Individual Success ? */
266 ret = mi_lttng_writer_write_element_bool(writer,
267 mi_lttng_element_command_success, success);
268 if (ret) {
269 ret = CMD_ERROR;
270 goto error;
271 }
272
273 /* Close channel element */
274 ret = mi_lttng_writer_close_element(writer);
275 if (ret) {
276 ret = CMD_ERROR;
277 goto error;
278 }
d36b8583
DG
279 }
280
acc09215 281 /* Next channel */
d36b8583
DG
282 channel_name = strtok(NULL, ",");
283 }
284
acc09215
JRJ
285 if (lttng_opt_mi) {
286 /* Close channels element */
287 ret = mi_lttng_writer_close_element(writer);
288 if (ret) {
289 ret = CMD_ERROR;
290 goto error;
291 }
292 }
293
ae856491
DG
294 ret = CMD_SUCCESS;
295
d36b8583 296error:
acc09215
JRJ
297 /* If more important error happen bypass the warning */
298 if (!ret && warn) {
ae856491
DG
299 ret = CMD_WARNING;
300 }
acc09215
JRJ
301 /* If more important error happen bypass the warning */
302 if (!ret && error) {
303 ret = CMD_ERROR;
304 }
ae856491 305
cd80958d
DG
306 lttng_destroy_handle(handle);
307
d36b8583
DG
308 return ret;
309}
310
311/*
0fdd1e2c 312 * Default value for channel configuration.
7d29a247
DG
313 */
314static void init_channel_config(void)
315{
5edd7e09
DG
316 /*
317 * Put -1 everywhere so we can identify those set by the command line and
318 * those needed to be set by the default values.
319 */
320 memset(&chan.attr, -1, sizeof(chan.attr));
394ff38e 321 chan.attr.extended.ptr = NULL;
7d29a247
DG
322}
323
324/*
0fdd1e2c 325 * Add channel to trace session
d36b8583
DG
326 */
327int cmd_enable_channels(int argc, const char **argv)
328{
acc09215 329 int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
d36b8583 330 static poptContext pc;
cd80958d 331 char *session_name = NULL;
70d0b120 332 char *opt_arg = NULL;
266d3dd0 333 const char *leftover = NULL;
d36b8583 334
7d29a247
DG
335 init_channel_config();
336
d36b8583
DG
337 pc = poptGetContext(NULL, argc, argv, long_options, 0);
338 poptReadDefaultConfig(pc, 0);
339
340 while ((opt = poptGetNextOpt(pc)) != -1) {
341 switch (opt) {
342 case OPT_HELP:
4ba92f18 343 SHOW_HELP();
d36b8583 344 goto end;
7d29a247
DG
345 case OPT_DISCARD:
346 chan.attr.overwrite = 0;
347 DBG("Channel set to discard");
348 break;
349 case OPT_OVERWRITE:
350 chan.attr.overwrite = 1;
351 DBG("Channel set to overwrite");
352 break;
353 case OPT_SUBBUF_SIZE:
1cb514ce
MD
354 {
355 uint64_t rounded_size;
356 int order;
357
70d0b120
SM
358 /* Parse the size */
359 opt_arg = poptGetOptArg(pc);
1cb514ce
MD
360 if (utils_parse_size_suffix(opt_arg, &chan.attr.subbuf_size) < 0 || !chan.attr.subbuf_size) {
361 ERR("Wrong value in --subbuf-size parameter: %s", opt_arg);
70d0b120
SM
362 ret = CMD_ERROR;
363 goto end;
364 }
365
1cb514ce
MD
366 order = get_count_order_u64(chan.attr.subbuf_size);
367 assert(order >= 0);
368 rounded_size = 1ULL << order;
06c0da96
DG
369 if (rounded_size < chan.attr.subbuf_size) {
370 ERR("The subbuf size (%" PRIu64 ") is rounded and overflows!",
371 chan.attr.subbuf_size);
372 ret = CMD_ERROR;
373 goto end;
374 }
375
1cb514ce
MD
376 if (rounded_size != chan.attr.subbuf_size) {
377 WARN("The subbuf size (%" PRIu64 ") is rounded to the next power of 2 (%" PRIu64 ")",
378 chan.attr.subbuf_size, rounded_size);
379 chan.attr.subbuf_size = rounded_size;
70d0b120
SM
380 }
381
1cb514ce
MD
382 /* Should now be power of 2 */
383 assert(!((chan.attr.subbuf_size - 1) & chan.attr.subbuf_size));
384
5a0de755 385 DBG("Channel subbuf size set to %" PRIu64, chan.attr.subbuf_size);
7d29a247 386 break;
1cb514ce 387 }
7d29a247 388 case OPT_NUM_SUBBUF:
1cb514ce
MD
389 {
390 uint64_t rounded_size;
391 int order;
392
16068db5 393 errno = 0;
1cb514ce
MD
394 opt_arg = poptGetOptArg(pc);
395 chan.attr.num_subbuf = strtoull(opt_arg, NULL, 0);
396 if (errno != 0 || !chan.attr.num_subbuf || !isdigit(opt_arg[0])) {
397 ERR("Wrong value in --num-subbuf parameter: %s", opt_arg);
16068db5
MD
398 ret = CMD_ERROR;
399 goto end;
400 }
401
1cb514ce
MD
402 order = get_count_order_u64(chan.attr.num_subbuf);
403 assert(order >= 0);
404 rounded_size = 1ULL << order;
e123b80c 405 if (rounded_size < chan.attr.num_subbuf) {
06c0da96
DG
406 ERR("The number of subbuffers (%" PRIu64 ") is rounded and overflows!",
407 chan.attr.num_subbuf);
408 ret = CMD_ERROR;
409 goto end;
410 }
411
1cb514ce
MD
412 if (rounded_size != chan.attr.num_subbuf) {
413 WARN("The number of subbuffers (%" PRIu64 ") is rounded to the next power of 2 (%" PRIu64 ")",
414 chan.attr.num_subbuf, rounded_size);
415 chan.attr.num_subbuf = rounded_size;
416 }
417
418 /* Should now be power of 2 */
419 assert(!((chan.attr.num_subbuf - 1) & chan.attr.num_subbuf));
420
5a0de755 421 DBG("Channel subbuf num set to %" PRIu64, chan.attr.num_subbuf);
7d29a247 422 break;
1cb514ce 423 }
7d29a247 424 case OPT_SWITCH_TIMER:
16068db5
MD
425 {
426 unsigned long v;
427
428 errno = 0;
1cb514ce
MD
429 opt_arg = poptGetOptArg(pc);
430 v = strtoul(opt_arg, NULL, 0);
431 if (errno != 0 || !isdigit(opt_arg[0])) {
432 ERR("Wrong value in --switch-timer parameter: %s", opt_arg);
16068db5
MD
433 ret = CMD_ERROR;
434 goto end;
435 }
436 if (v != (uint32_t) v) {
437 ERR("32-bit overflow in --switch-timer parameter: %s", opt_arg);
438 ret = CMD_ERROR;
439 goto end;
440 }
441 chan.attr.switch_timer_interval = (uint32_t) v;
7d29a247
DG
442 DBG("Channel switch timer interval set to %d", chan.attr.switch_timer_interval);
443 break;
16068db5 444 }
7d29a247 445 case OPT_READ_TIMER:
16068db5
MD
446 {
447 unsigned long v;
448
449 errno = 0;
1cb514ce
MD
450 opt_arg = poptGetOptArg(pc);
451 v = strtoul(opt_arg, NULL, 0);
452 if (errno != 0 || !isdigit(opt_arg[0])) {
453 ERR("Wrong value in --read-timer parameter: %s", opt_arg);
16068db5
MD
454 ret = CMD_ERROR;
455 goto end;
456 }
457 if (v != (uint32_t) v) {
458 ERR("32-bit overflow in --read-timer parameter: %s", opt_arg);
459 ret = CMD_ERROR;
460 goto end;
461 }
462 chan.attr.read_timer_interval = (uint32_t) v;
7d29a247 463 DBG("Channel read timer interval set to %d", chan.attr.read_timer_interval);
d36b8583 464 break;
16068db5 465 }
eeac7d46
MD
466 case OPT_USERSPACE:
467 opt_userspace = 1;
eeac7d46 468 break;
1624d5b7 469 case OPT_TRACEFILE_SIZE:
1cb514ce 470 opt_arg = poptGetOptArg(pc);
16068db5 471 if (utils_parse_size_suffix(opt_arg, &chan.attr.tracefile_size) < 0) {
1cb514ce 472 ERR("Wrong value in --tracefile-size parameter: %s", opt_arg);
16068db5
MD
473 ret = CMD_ERROR;
474 goto end;
475 }
1624d5b7
JD
476 DBG("Maximum tracefile size set to %" PRIu64,
477 chan.attr.tracefile_size);
478 break;
479 case OPT_TRACEFILE_COUNT:
16068db5
MD
480 {
481 unsigned long v;
482
483 errno = 0;
1cb514ce
MD
484 opt_arg = poptGetOptArg(pc);
485 v = strtoul(opt_arg, NULL, 0);
486 if (errno != 0 || !isdigit(opt_arg[0])) {
487 ERR("Wrong value in --tracefile-count parameter: %s", opt_arg);
16068db5
MD
488 ret = CMD_ERROR;
489 goto end;
490 }
491 if (v != (uint32_t) v) {
492 ERR("32-bit overflow in --tracefile-count parameter: %s", opt_arg);
493 ret = CMD_ERROR;
494 goto end;
495 }
496 chan.attr.tracefile_count = (uint32_t) v;
1624d5b7
JD
497 DBG("Maximum tracefile count set to %" PRIu64,
498 chan.attr.tracefile_count);
499 break;
16068db5 500 }
679b4943
SM
501 case OPT_LIST_OPTIONS:
502 list_cmd_options(stdout, long_options);
679b4943 503 goto end;
d36b8583 504 default:
d36b8583
DG
505 ret = CMD_UNDEFINED;
506 goto end;
507 }
508 }
509
3ecec76a
PP
510 ret = print_missing_or_multiple_domains(opt_kernel + opt_userspace);
511 if (ret) {
512 ret = CMD_ERROR;
513 goto end;
514 }
515
acc09215
JRJ
516 /* Mi check */
517 if (lttng_opt_mi) {
518 writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
519 if (!writer) {
520 ret = -LTTNG_ERR_NOMEM;
521 goto end;
522 }
523
524 /* Open command element */
525 ret = mi_lttng_writer_command_open(writer,
526 mi_lttng_element_command_enable_channels);
527 if (ret) {
528 ret = CMD_ERROR;
529 goto end;
530 }
531
532 /* Open output element */
533 ret = mi_lttng_writer_open_element(writer,
534 mi_lttng_element_command_output);
535 if (ret) {
536 ret = CMD_ERROR;
537 goto end;
538 }
539 }
540
d36b8583
DG
541 opt_channels = (char*) poptGetArg(pc);
542 if (opt_channels == NULL) {
7d29a247 543 ERR("Missing channel name.\n");
ca1c3607 544 ret = CMD_ERROR;
acc09215
JRJ
545 success = 0;
546 goto mi_closing;
d36b8583
DG
547 }
548
266d3dd0
JD
549 leftover = poptGetArg(pc);
550 if (leftover) {
551 ERR("Unknown argument: %s", leftover);
552 ret = CMD_ERROR;
553 success = 0;
554 goto mi_closing;
555 }
556
cd80958d
DG
557 if (!opt_session_name) {
558 session_name = get_session_name();
559 if (session_name == NULL) {
acc09215
JRJ
560 command_ret = CMD_ERROR;
561 success = 0;
562 goto mi_closing;
cd80958d
DG
563 }
564 } else {
565 session_name = opt_session_name;
566 }
567
acc09215
JRJ
568 command_ret = enable_channel(session_name);
569 if (command_ret) {
570 success = 0;
571 }
572
573mi_closing:
574 /* Mi closing */
575 if (lttng_opt_mi) {
576 /* Close output element */
577 ret = mi_lttng_writer_close_element(writer);
578 if (ret) {
579 goto end;
580 }
581
582 /* Success ? */
583 ret = mi_lttng_writer_write_element_bool(writer,
584 mi_lttng_element_command_success, success);
585 if (ret) {
586 goto end;
587 }
588
589 /* Command element close */
590 ret = mi_lttng_writer_command_close(writer);
591 if (ret) {
592 goto end;
593 }
594 }
d36b8583
DG
595
596end:
acc09215
JRJ
597 /* Mi clean-up */
598 if (writer && mi_lttng_writer_destroy(writer)) {
599 /* Preserve original error code */
600 ret = ret ? ret : LTTNG_ERR_MI_IO_FAIL;
601 }
602
5853fd43
DG
603 if (!opt_session_name && session_name) {
604 free(session_name);
605 }
acc09215
JRJ
606
607 /* Overwrite ret if an error occurred when enable_channel */
608 ret = command_ret ? command_ret : ret;
ca1c3607 609 poptFreeContext(pc);
d36b8583
DG
610 return ret;
611}
This page took 0.103746 seconds and 5 git commands to generate.