Run clang-format on the whole tree
[lttng-tools.git] / src / bin / lttng-sessiond / channel.cpp
CommitLineData
54d01ffb 1/*
21cf9b6b 2 * Copyright (C) 2011 EfficiOS Inc.
ab5be9fa 3 * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
54d01ffb 4 *
ab5be9fa 5 * SPDX-License-Identifier: GPL-2.0-only
54d01ffb 6 *
54d01ffb
DG
7 */
8
6c1c0768 9#define _LGPL_SOURCE
28ab034a 10#include "agent.hpp"
c9e313bc 11#include "channel.hpp"
c9e313bc 12#include "kernel.hpp"
28ab034a 13#include "lttng-sessiond.hpp"
c9e313bc
SM
14#include "lttng-ust-ctl.hpp"
15#include "lttng-ust-error.hpp"
c9e313bc 16#include "ust-app.hpp"
28ab034a
JG
17#include "utils.hpp"
18
19#include <common/common.hpp>
20#include <common/defaults.hpp>
21#include <common/sessiond-comm/sessiond-comm.hpp>
22
23#include <inttypes.h>
24#include <string.h>
25#include <unistd.h>
54d01ffb
DG
26
27/*
28 * Return allocated channel attributes.
29 */
28ab034a 30struct lttng_channel *channel_new_default_attr(int dom, enum lttng_buffer_type type)
54d01ffb
DG
31{
32 struct lttng_channel *chan;
bdf64013 33 const char *channel_name = DEFAULT_CHANNEL_NAME;
e9404c27 34 struct lttng_channel_extended *extended_attr = NULL;
54d01ffb 35
64803277 36 chan = zmalloc<lttng_channel>();
54d01ffb 37 if (chan == NULL) {
7885e399 38 PERROR("zmalloc channel init");
54d01ffb
DG
39 goto error_alloc;
40 }
41
64803277 42 extended_attr = zmalloc<lttng_channel_extended>();
e9404c27
JG
43 if (!extended_attr) {
44 PERROR("zmalloc channel extended init");
45 goto error;
46 }
47
48 chan->attr.extended.ptr = extended_attr;
49
0a9c6494 50 /* Same for all domains. */
54d01ffb 51 chan->attr.overwrite = DEFAULT_CHANNEL_OVERWRITE;
0a9c6494
DG
52 chan->attr.tracefile_size = DEFAULT_CHANNEL_TRACEFILE_SIZE;
53 chan->attr.tracefile_count = DEFAULT_CHANNEL_TRACEFILE_COUNT;
54d01ffb
DG
54
55 switch (dom) {
1b1c65fa 56 case LTTNG_DOMAIN_KERNEL:
a0377dfe 57 LTTNG_ASSERT(type == LTTNG_BUFFER_GLOBAL);
28ab034a 58 chan->attr.subbuf_size = default_get_kernel_channel_subbuf_size();
1b1c65fa
MD
59 chan->attr.num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM;
60 chan->attr.output = DEFAULT_KERNEL_CHANNEL_OUTPUT;
6bb9e85f
MD
61 chan->attr.switch_timer_interval = DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER;
62 chan->attr.read_timer_interval = DEFAULT_KERNEL_CHANNEL_READ_TIMER;
ecc48a90 63 chan->attr.live_timer_interval = DEFAULT_KERNEL_CHANNEL_LIVE_TIMER;
491d1539 64 extended_attr->blocking_timeout = DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT;
28ab034a 65 extended_attr->monitor_timer_interval = DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER;
1b1c65fa 66 break;
bdf64013
JG
67 case LTTNG_DOMAIN_JUL:
68 channel_name = DEFAULT_JUL_CHANNEL_NAME;
69 goto common_ust;
70 case LTTNG_DOMAIN_LOG4J:
71 channel_name = DEFAULT_LOG4J_CHANNEL_NAME;
72 goto common_ust;
73 case LTTNG_DOMAIN_PYTHON:
74 channel_name = DEFAULT_PYTHON_CHANNEL_NAME;
75 goto common_ust;
1b1c65fa 76 case LTTNG_DOMAIN_UST:
28ab034a 77 common_ust:
0a9c6494
DG
78 switch (type) {
79 case LTTNG_BUFFER_PER_UID:
80 chan->attr.subbuf_size = default_get_ust_uid_channel_subbuf_size();
81 chan->attr.num_subbuf = DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM;
82 chan->attr.output = DEFAULT_UST_UID_CHANNEL_OUTPUT;
28ab034a
JG
83 chan->attr.switch_timer_interval = DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER;
84 chan->attr.read_timer_interval = DEFAULT_UST_UID_CHANNEL_READ_TIMER;
85 chan->attr.live_timer_interval = DEFAULT_UST_UID_CHANNEL_LIVE_TIMER;
491d1539 86 extended_attr->blocking_timeout = DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT;
e9404c27
JG
87 extended_attr->monitor_timer_interval =
88 DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER;
0a9c6494
DG
89 break;
90 case LTTNG_BUFFER_PER_PID:
91 default:
92 chan->attr.subbuf_size = default_get_ust_pid_channel_subbuf_size();
93 chan->attr.num_subbuf = DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM;
94 chan->attr.output = DEFAULT_UST_PID_CHANNEL_OUTPUT;
28ab034a
JG
95 chan->attr.switch_timer_interval = DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER;
96 chan->attr.read_timer_interval = DEFAULT_UST_PID_CHANNEL_READ_TIMER;
97 chan->attr.live_timer_interval = DEFAULT_UST_PID_CHANNEL_LIVE_TIMER;
491d1539 98 extended_attr->blocking_timeout = DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT;
e9404c27
JG
99 extended_attr->monitor_timer_interval =
100 DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER;
0a9c6494
DG
101 break;
102 }
1b1c65fa
MD
103 break;
104 default:
28ab034a 105 goto error; /* Not implemented */
54d01ffb
DG
106 }
107
28ab034a 108 if (snprintf(chan->name, sizeof(chan->name), "%s", channel_name) < 0) {
bdf64013
JG
109 PERROR("snprintf default channel name");
110 goto error;
111 }
54d01ffb
DG
112 return chan;
113
114error:
e9404c27 115 free(extended_attr);
54d01ffb
DG
116 free(chan);
117error_alloc:
118 return NULL;
119}
120
e9404c27
JG
121void channel_attr_destroy(struct lttng_channel *channel)
122{
123 if (!channel) {
124 return;
125 }
126 free(channel->attr.extended.ptr);
127 free(channel);
128}
129
54d01ffb
DG
130/*
131 * Disable kernel channel of the kernel session.
132 */
28ab034a 133int channel_kernel_disable(struct ltt_kernel_session *ksession, char *channel_name)
54d01ffb
DG
134{
135 int ret;
136 struct ltt_kernel_channel *kchan;
137
a0377dfe
FD
138 LTTNG_ASSERT(ksession);
139 LTTNG_ASSERT(channel_name);
0525e9ae 140
54d01ffb
DG
141 kchan = trace_kernel_get_channel_by_name(channel_name, ksession);
142 if (kchan == NULL) {
f73fabfd 143 ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND;
54d01ffb 144 goto error;
0525e9ae
DG
145 }
146
147 /* Only if channel is enabled disable it. */
148 if (kchan->enabled == 1) {
54d01ffb 149 ret = kernel_disable_channel(kchan);
7885e399 150 if (ret < 0 && ret != -EEXIST) {
f73fabfd 151 ret = LTTNG_ERR_KERN_CHAN_DISABLE_FAIL;
54d01ffb
DG
152 goto error;
153 }
154 }
155
f73fabfd 156 ret = LTTNG_OK;
54d01ffb
DG
157
158error:
159 return ret;
160}
161
162/*
163 * Enable kernel channel of the kernel session.
164 */
4878de5c 165enum lttng_error_code channel_kernel_enable(struct ltt_kernel_session *ksession,
28ab034a 166 struct ltt_kernel_channel *kchan)
54d01ffb 167{
4878de5c 168 enum lttng_error_code ret_code;
54d01ffb 169
a0377dfe
FD
170 LTTNG_ASSERT(ksession);
171 LTTNG_ASSERT(kchan);
0525e9ae 172
54d01ffb 173 if (kchan->enabled == 0) {
4878de5c
JG
174 if (kernel_enable_channel(kchan) < 0) {
175 ret_code = LTTNG_ERR_KERN_CHAN_ENABLE_FAIL;
54d01ffb
DG
176 goto error;
177 }
42224349 178 } else {
4878de5c 179 ret_code = LTTNG_ERR_KERN_CHAN_EXIST;
42224349 180 goto error;
54d01ffb
DG
181 }
182
4878de5c 183 ret_code = LTTNG_OK;
54d01ffb
DG
184
185error:
4878de5c 186 return ret_code;
54d01ffb
DG
187}
188
da9d9d9c
MD
189static int channel_validate(struct lttng_channel *attr)
190{
191 /*
192 * The ringbuffer (both in user space and kernel) behaves badly
193 * in overwrite mode and with less than 2 subbuffers so block it
194 * right away and send back an invalid attribute error.
195 */
196 if (attr->attr.overwrite && attr->attr.num_subbuf < 2) {
197 return -1;
198 }
199 return 0;
200}
201
491d1539
MD
202static int channel_validate_kernel(struct lttng_channel *attr)
203{
204 /* Kernel channels do not support blocking timeout. */
28ab034a 205 if (((struct lttng_channel_extended *) attr->attr.extended.ptr)->blocking_timeout) {
491d1539
MD
206 return -1;
207 }
208 return 0;
209}
210
54d01ffb
DG
211/*
212 * Create kernel channel of the kernel session and notify kernel thread.
213 */
4878de5c 214enum lttng_error_code channel_kernel_create(struct ltt_kernel_session *ksession,
28ab034a
JG
215 struct lttng_channel *attr,
216 int kernel_pipe)
54d01ffb 217{
4878de5c 218 enum lttng_error_code ret_code;
ff4d74e6 219 struct lttng_channel *defattr = NULL;
54d01ffb 220
a0377dfe 221 LTTNG_ASSERT(ksession);
0525e9ae 222
54d01ffb
DG
223 /* Creating channel attributes if needed */
224 if (attr == NULL) {
28ab034a 225 defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL, LTTNG_BUFFER_GLOBAL);
ff4d74e6 226 if (defattr == NULL) {
4878de5c 227 ret_code = LTTNG_ERR_FATAL;
54d01ffb
DG
228 goto error;
229 }
ff4d74e6 230 attr = defattr;
54d01ffb
DG
231 }
232
8d5841ea
MD
233 /*
234 * Set the overwrite mode for this channel based on the session
235 * type unless the client explicitly overrides the channel mode.
236 */
237 if (attr->attr.overwrite == DEFAULT_CHANNEL_OVERWRITE) {
238 attr->attr.overwrite = !!ksession->snapshot_mode;
239 }
240
da9d9d9c
MD
241 /* Validate common channel properties. */
242 if (channel_validate(attr) < 0) {
4878de5c 243 ret_code = LTTNG_ERR_INVALID;
da9d9d9c
MD
244 goto error;
245 }
246
491d1539 247 if (channel_validate_kernel(attr) < 0) {
4878de5c 248 ret_code = LTTNG_ERR_INVALID;
491d1539
MD
249 goto error;
250 }
251
4878de5c
JG
252 /* Channel not found, creating it. */
253 if (kernel_create_channel(ksession, attr) < 0) {
254 ret_code = LTTNG_ERR_KERN_CHAN_FAIL;
54d01ffb
DG
255 goto error;
256 }
257
258 /* Notify kernel thread that there is a new channel */
4878de5c
JG
259 if (notify_thread_pipe(kernel_pipe) < 0) {
260 ret_code = LTTNG_ERR_FATAL;
54d01ffb
DG
261 goto error;
262 }
263
4878de5c 264 ret_code = LTTNG_OK;
54d01ffb 265error:
e9404c27 266 channel_attr_destroy(defattr);
4878de5c 267 return ret_code;
54d01ffb 268}
7885e399
DG
269
270/*
271 * Enable UST channel for session and domain.
272 */
4878de5c 273enum lttng_error_code channel_ust_enable(struct ltt_ust_session *usess,
28ab034a 274 struct ltt_ust_channel *uchan)
7885e399 275{
4878de5c 276 enum lttng_error_code ret_code = LTTNG_OK;
7885e399 277
a0377dfe
FD
278 LTTNG_ASSERT(usess);
279 LTTNG_ASSERT(uchan);
0525e9ae 280
7885e399
DG
281 /* If already enabled, everything is OK */
282 if (uchan->enabled) {
283 DBG3("Channel %s already enabled. Skipping", uchan->name);
4878de5c 284 ret_code = LTTNG_ERR_UST_CHAN_EXIST;
7885e399 285 goto end;
88e3c2f5
JG
286 } else {
287 uchan->enabled = 1;
288 DBG2("Channel %s enabled successfully", uchan->name);
289 }
290
291 if (!usess->active) {
292 /*
293 * The channel will be activated against the apps
294 * when the session is started as part of the
295 * application channel "synchronize" operation.
296 */
297 goto end;
7885e399
DG
298 }
299
7972aab2
DG
300 DBG2("Channel %s being enabled in UST domain", uchan->name);
301
302 /*
303 * Enable channel for UST global domain on all applications. Ignore return
304 * value here since whatever error we got, it means that the channel was
305 * not created on one or many registered applications and we can not report
306 * this to the user yet. However, at this stage, the channel was
307 * successfully created on the session daemon side so the enable-channel
308 * command is a success.
309 */
d54b4440 310 (void) ust_app_enable_channel_glb(usess, uchan);
7885e399 311
7885e399 312end:
4878de5c 313 return ret_code;
7885e399
DG
314}
315
316/*
317 * Create UST channel for session and domain.
318 */
4878de5c 319enum lttng_error_code channel_ust_create(struct ltt_ust_session *usess,
28ab034a
JG
320 struct lttng_channel *attr,
321 enum lttng_buffer_type type)
7885e399 322{
4878de5c 323 enum lttng_error_code ret_code = LTTNG_OK;
7885e399
DG
324 struct ltt_ust_channel *uchan = NULL;
325 struct lttng_channel *defattr = NULL;
b63d638b 326 enum lttng_domain_type domain = LTTNG_DOMAIN_UST;
f86e086c 327 bool chan_published = false;
7885e399 328
a0377dfe 329 LTTNG_ASSERT(usess);
0525e9ae 330
7885e399
DG
331 /* Creating channel attributes if needed */
332 if (attr == NULL) {
0a9c6494 333 defattr = channel_new_default_attr(LTTNG_DOMAIN_UST, type);
7885e399 334 if (defattr == NULL) {
4878de5c 335 ret_code = LTTNG_ERR_FATAL;
7885e399
DG
336 goto error;
337 }
338 attr = defattr;
b63d638b
JG
339 } else {
340 /*
341 * HACK: Set the channel's subdomain (JUL, Log4j, Python, etc.)
342 * based on the default name.
343 */
344 if (!strcmp(attr->name, DEFAULT_JUL_CHANNEL_NAME)) {
345 domain = LTTNG_DOMAIN_JUL;
346 } else if (!strcmp(attr->name, DEFAULT_LOG4J_CHANNEL_NAME)) {
347 domain = LTTNG_DOMAIN_LOG4J;
348 } else if (!strcmp(attr->name, DEFAULT_PYTHON_CHANNEL_NAME)) {
349 domain = LTTNG_DOMAIN_PYTHON;
350 }
7885e399
DG
351 }
352
8d5841ea
MD
353 /*
354 * Set the overwrite mode for this channel based on the session
355 * type unless the client explicitly overrides the channel mode.
356 */
357 if (attr->attr.overwrite == DEFAULT_CHANNEL_OVERWRITE) {
358 attr->attr.overwrite = !!usess->snapshot_mode;
359 }
360
361 /* Enforce mmap output for snapshot sessions. */
27babd3a 362 if (usess->snapshot_mode) {
27babd3a
DG
363 attr->attr.output = LTTNG_EVENT_MMAP;
364 }
365
da9d9d9c
MD
366 /* Validate common channel properties. */
367 if (channel_validate(attr) < 0) {
4878de5c 368 ret_code = LTTNG_ERR_INVALID;
da9d9d9c
MD
369 goto error;
370 }
371
b024d072 372 /*
0525e9ae
DG
373 * Validate UST buffer size and number of buffers: must both be power of 2
374 * and nonzero. We validate right here for UST, because applications will
375 * not report the error to the user (unlike kernel tracing).
b024d072 376 */
28ab034a 377 if (!attr->attr.subbuf_size || (attr->attr.subbuf_size & (attr->attr.subbuf_size - 1))) {
4878de5c 378 ret_code = LTTNG_ERR_INVALID;
b024d072
MD
379 goto error;
380 }
0525e9ae 381
12744796
DG
382 /*
383 * Invalid subbuffer size if it's lower then the page size.
384 */
412d7227 385 if (attr->attr.subbuf_size < the_page_size) {
4878de5c 386 ret_code = LTTNG_ERR_INVALID;
12744796
DG
387 goto error;
388 }
389
28ab034a 390 if (!attr->attr.num_subbuf || (attr->attr.num_subbuf & (attr->attr.num_subbuf - 1))) {
4878de5c 391 ret_code = LTTNG_ERR_INVALID;
b024d072
MD
392 goto error;
393 }
394
a79d84dd 395 if (attr->attr.output != LTTNG_EVENT_MMAP) {
4878de5c 396 ret_code = LTTNG_ERR_NOT_SUPPORTED;
a79d84dd
DG
397 goto error;
398 }
399
1624d5b7
JD
400 /*
401 * The tracefile_size should not be < to the subbuf_size, otherwise
402 * we won't be able to write the packets on disk
403 */
404 if ((attr->attr.tracefile_size > 0) &&
28ab034a 405 (attr->attr.tracefile_size < attr->attr.subbuf_size)) {
4878de5c 406 ret_code = LTTNG_ERR_INVALID;
1624d5b7
JD
407 goto error;
408 }
409
2e8269f7
DG
410 /* Validate buffer type. */
411 switch (type) {
412 case LTTNG_BUFFER_PER_PID:
0a9c6494 413 break;
2e8269f7
DG
414 case LTTNG_BUFFER_PER_UID:
415 break;
416 default:
4878de5c 417 ret_code = LTTNG_ERR_BUFFER_NOT_SUPPORTED;
2e8269f7
DG
418 goto error;
419 }
420
7885e399 421 /* Create UST channel */
b63d638b 422 uchan = trace_ust_create_channel(attr, domain);
7885e399 423 if (uchan == NULL) {
4878de5c 424 ret_code = LTTNG_ERR_FATAL;
7885e399
DG
425 goto error;
426 }
51755dc8 427
58f3ca76 428 uchan->enabled = 1;
7972aab2 429 if (trace_ust_is_max_id(usess->used_channel_id)) {
4878de5c 430 ret_code = LTTNG_ERR_UST_CHAN_FAIL;
7972aab2
DG
431 goto error;
432 }
433 uchan->id = trace_ust_get_next_chan_id(usess);
434
435 DBG2("Channel %s is being created for UST with buffer %d and id %" PRIu64,
28ab034a
JG
436 uchan->name,
437 type,
438 uchan->id);
7972aab2
DG
439
440 /* Flag session buffer type. */
441 if (!usess->buffer_type_changed) {
442 usess->buffer_type = type;
443 usess->buffer_type_changed = 1;
444 } else if (usess->buffer_type != type) {
445 /* Buffer type was already set. Refuse to create channel. */
4878de5c 446 ret_code = LTTNG_ERR_BUFFER_TYPE_MISMATCH;
7885e399
DG
447 goto error_free_chan;
448 }
449
fc34caaa
DG
450 /* Adding the channel to the channel hash table. */
451 rcu_read_lock();
28ab034a 452 if (strncmp(uchan->name, DEFAULT_METADATA_NAME, sizeof(uchan->name))) {
ad7a9107 453 lttng_ht_add_unique_str(usess->domain_global.channels, &uchan->node);
f86e086c 454 chan_published = true;
84ad93e8
DG
455 } else {
456 /*
457 * Copy channel attribute to session if this is metadata so if NO
458 * application exists we can access that data in the shadow copy during
459 * the global update of newly registered application.
460 */
28ab034a 461 memcpy(&usess->metadata_attr, &uchan->attr, sizeof(usess->metadata_attr));
ad7a9107 462 }
fc34caaa
DG
463 rcu_read_unlock();
464
7885e399 465 DBG2("Channel %s created successfully", uchan->name);
b63d638b
JG
466 if (domain != LTTNG_DOMAIN_UST) {
467 struct agent *agt = trace_ust_find_agent(usess, domain);
468
469 if (!agt) {
470 agt = agent_create(domain);
471 if (!agt) {
4878de5c 472 ret_code = LTTNG_ERR_NOMEM;
f86e086c 473 goto error_remove_chan;
b63d638b
JG
474 }
475 agent_add(agt, usess->agents);
476 }
477 }
7885e399 478
e9404c27 479 channel_attr_destroy(defattr);
f73fabfd 480 return LTTNG_OK;
7885e399 481
f86e086c
MD
482error_remove_chan:
483 if (chan_published) {
484 trace_ust_delete_channel(usess->domain_global.channels, uchan);
485 }
7885e399
DG
486error_free_chan:
487 trace_ust_destroy_channel(uchan);
488error:
e9404c27 489 channel_attr_destroy(defattr);
4878de5c 490 return ret_code;
7885e399
DG
491}
492
493/*
494 * Disable UST channel for session and domain.
495 */
28ab034a 496int channel_ust_disable(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan)
7885e399 497{
f73fabfd 498 int ret = LTTNG_OK;
7885e399 499
a0377dfe
FD
500 LTTNG_ASSERT(usess);
501 LTTNG_ASSERT(uchan);
0525e9ae 502
7885e399
DG
503 /* Already disabled */
504 if (uchan->enabled == 0) {
505 DBG2("Channel UST %s already disabled", uchan->name);
506 goto end;
507 }
fbee8987
FD
508
509 uchan->enabled = 0;
510
511 /*
512 * If session is inactive we don't notify the tracer right away. We
513 * wait for the next synchronization.
514 */
88e3c2f5
JG
515 if (!usess->active) {
516 goto end;
517 }
7885e399 518
7972aab2
DG
519 DBG2("Channel %s being disabled in UST global domain", uchan->name);
520 /* Disable channel for global domain */
521 ret = ust_app_disable_channel_glb(usess, uchan);
49c336c1 522 if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) {
f73fabfd 523 ret = LTTNG_ERR_UST_CHAN_DISABLE_FAIL;
7885e399
DG
524 goto error;
525 }
526
7885e399
DG
527 DBG2("Channel %s disabled successfully", uchan->name);
528
f73fabfd 529 return LTTNG_OK;
7885e399
DG
530
531end:
532error:
533 return ret;
534}
999af9c1 535
28ab034a 536struct lttng_channel *trace_ust_channel_to_lttng_channel(const struct ltt_ust_channel *uchan)
999af9c1
JR
537{
538 struct lttng_channel *channel = NULL, *ret = NULL;
539
540 channel = lttng_channel_create_internal();
541 if (!channel) {
542 ERR("Failed to create lttng_channel during conversion from ltt_ust_channel to lttng_channel");
543 goto end;
544 }
545
546 if (lttng_strncpy(channel->name, uchan->name, LTTNG_SYMBOL_NAME_LEN)) {
547 ERR("Failed to set channel name during conversion from ltt_ust_channel to lttng_channel");
548 goto end;
549 }
550
551 channel->attr.overwrite = uchan->attr.overwrite;
552 channel->attr.subbuf_size = uchan->attr.subbuf_size;
553 channel->attr.num_subbuf = uchan->attr.num_subbuf;
554 channel->attr.switch_timer_interval = uchan->attr.switch_timer_interval;
555 channel->attr.read_timer_interval = uchan->attr.read_timer_interval;
556 channel->enabled = uchan->enabled;
557 channel->attr.tracefile_size = uchan->tracefile_size;
558 channel->attr.tracefile_count = uchan->tracefile_count;
559
560 /*
561 * Map enum lttng_ust_output to enum lttng_event_output.
562 */
563 switch (uchan->attr.output) {
564 case LTTNG_UST_ABI_MMAP:
565 channel->attr.output = LTTNG_EVENT_MMAP;
566 break;
567 default:
568 /*
569 * LTTNG_UST_MMAP is the only supported UST
570 * output mode.
571 */
572 abort();
573 break;
574 }
575
28ab034a
JG
576 lttng_channel_set_blocking_timeout(channel, uchan->attr.u.s.blocking_timeout);
577 lttng_channel_set_monitor_timer_interval(channel, uchan->monitor_timer_interval);
999af9c1
JR
578
579 ret = channel;
580 channel = NULL;
581
582end:
583 lttng_channel_destroy(channel);
584 return ret;
585}
This page took 0.10337 seconds and 4 git commands to generate.