X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=lttng-sessiond%2Fchannel.c;h=6b3329edd301f247a0ed1f641ee829f2f0a065c5;hp=fda679c78f3ebacfbee3ff9d52b4aabb25228cdc;hb=1b1c65fad7e196d52a3333450302096c14937874;hpb=322585731ced1adba36cddcb8bdd5d997d1b2e3e diff --git a/lttng-sessiond/channel.c b/lttng-sessiond/channel.c index fda679c78..6b3329edd 100644 --- a/lttng-sessiond/channel.c +++ b/lttng-sessiond/channel.c @@ -21,13 +21,6 @@ #include #include #include -#ifdef CONFIG_LTTNG_TOOLS_HAVE_UST -#include -#include -#else -#include "lttng-ust-ctl.h" -#include "lttng-ust-abi.h" -#endif #include "channel.h" #include "hashtable.h" @@ -44,7 +37,7 @@ struct lttng_channel *channel_new_default_attr(int dom) chan = zmalloc(sizeof(struct lttng_channel)); if (chan == NULL) { - perror("malloc channel init"); + perror("zmalloc channel init"); goto error_alloc; } @@ -59,19 +52,19 @@ struct lttng_channel *channel_new_default_attr(int dom) chan->attr.read_timer_interval = DEFAULT_CHANNEL_READ_TIMER; switch (dom) { - case LTTNG_DOMAIN_KERNEL: - chan->attr.subbuf_size = DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE; - chan->attr.num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM; - chan->attr.output = DEFAULT_KERNEL_CHANNEL_OUTPUT; - break; - case LTTNG_DOMAIN_UST: - case LTTNG_DOMAIN_UST_PID: - chan->attr.subbuf_size = DEFAULT_UST_CHANNEL_SUBBUF_SIZE; - chan->attr.num_subbuf = DEFAULT_UST_CHANNEL_SUBBUF_NUM; - chan->attr.output = DEFAULT_UST_CHANNEL_OUTPUT; - break; - default: - goto error; /* Not implemented */ + case LTTNG_DOMAIN_KERNEL: + chan->attr.subbuf_size = DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE; + chan->attr.num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM; + chan->attr.output = DEFAULT_KERNEL_CHANNEL_OUTPUT; + break; + case LTTNG_DOMAIN_UST: + case LTTNG_DOMAIN_UST_PID: + chan->attr.subbuf_size = DEFAULT_UST_CHANNEL_SUBBUF_SIZE; + chan->attr.num_subbuf = DEFAULT_UST_CHANNEL_SUBBUF_NUM; + chan->attr.output = DEFAULT_UST_CHANNEL_OUTPUT; + break; + default: + goto error; /* Not implemented */ } return chan; @@ -95,9 +88,9 @@ int channel_ust_copy(struct ltt_ust_channel *dst, /* cds_list_for_each_entry(uevent, &src->events.head, list) { - new_uevent = malloc(sizeof(struct ltt_ust_event)); + new_uevent = zmalloc(sizeof(struct ltt_ust_event)); if (new_uevent == NULL) { - perror("malloc ltt_ust_event"); + perror("zmalloc ltt_ust_event"); goto error; } @@ -168,19 +161,19 @@ error: * Create kernel channel of the kernel session and notify kernel thread. */ int channel_kernel_create(struct ltt_kernel_session *ksession, - struct lttng_channel *chan, int kernel_pipe) + struct lttng_channel *attr, int kernel_pipe) { int ret; - struct lttng_channel *attr = chan; + struct lttng_channel *defattr = NULL; /* Creating channel attributes if needed */ if (attr == NULL) { - /* FIXME: this appears to be a memory leak */ - attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL); - if (attr == NULL) { + defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL); + if (defattr == NULL) { ret = LTTCOMM_FATAL; goto error; } + attr = defattr; } /* Channel not found, creating it */ @@ -198,8 +191,8 @@ int channel_kernel_create(struct ltt_kernel_session *ksession, } ret = LTTCOMM_OK; - error: + free(defattr); return ret; }