X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=ltt-sessiond%2Fchannel.c;h=10635536c0fbcf5726a666ad9a25ce8d5897752b;hb=f84efadf55274918ca038a4e06e0a8af1a320654;hp=818f6dcfd476d7d586a480da6ebd2219d7709729;hpb=44d3bd014f6ad217cff7e7c3dfaad76b1927c37b;p=lttng-tools.git diff --git a/ltt-sessiond/channel.c b/ltt-sessiond/channel.c index 818f6dcfd..10635536c 100644 --- a/ltt-sessiond/channel.c +++ b/ltt-sessiond/channel.c @@ -15,6 +15,7 @@ * Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include @@ -29,7 +30,7 @@ /* * Return allocated channel attributes. */ -static struct lttng_channel *init_default_attr(int dom) +struct lttng_channel *channel_new_default_attr(int dom) { struct lttng_channel *chan; @@ -72,6 +73,35 @@ error_alloc: return NULL; } +/* + * Copy two ltt ust channel. Dst and src must be already allocated. + */ +int channel_ust_copy(struct ltt_ust_channel *dst, + struct ltt_ust_channel *src) +{ + struct ltt_ust_event *uevent, *new_uevent; + + memcpy(dst, src, sizeof(struct ltt_ust_channel)); + CDS_INIT_LIST_HEAD(&dst->events.head); + + cds_list_for_each_entry(uevent, &src->events.head, list) { + new_uevent = malloc(sizeof(struct ltt_ust_event)); + if (new_uevent == NULL) { + perror("malloc ltt_ust_event"); + goto error; + } + + memcpy(new_uevent, uevent, sizeof(struct ltt_ust_event)); + cds_list_add(&new_uevent->list, &dst->events.head); + dst->events.count++; + } + + return 0; + +error: + return -1; +} + /* * Disable kernel channel of the kernel session. */ @@ -134,7 +164,7 @@ int channel_kernel_create(struct ltt_kernel_session *ksession, /* Creating channel attributes if needed */ if (attr == NULL) { - attr = init_default_attr(LTTNG_DOMAIN_KERNEL); + attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL); if (attr == NULL) { ret = LTTCOMM_FATAL; goto error; @@ -172,7 +202,7 @@ int channel_ust_create(struct ltt_ust_session *usession, /* Creating channel attributes if needed */ if (attr == NULL) { - attr = init_default_attr(LTTNG_DOMAIN_UST_PID); + attr = channel_new_default_attr(LTTNG_DOMAIN_UST_PID); if (attr == NULL) { ret = LTTCOMM_FATAL; goto error;