X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fust-consumer%2Fust-consumer.c;h=44bcfdc374d9a0bd9b2ce869059fa912794a19c1;hb=69f60d21c627ad2fcae6d25fecf91e639c6ded33;hp=7dfcf9a3cf46381675222dfbcb94a474e0e8eaa9;hpb=c585821bc78955b3d747fcd733aa1d2b81a3258e;p=lttng-tools.git diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 7dfcf9a3c..44bcfdc37 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -16,7 +16,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #define _LGPL_SOURCE #include #include @@ -39,15 +38,15 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include "ust-consumer.h" -#define UINT_MAX_STR_LEN 11 /* includes \0 */ +#define INT_MAX_STR_LEN 12 /* includes \0 */ extern struct lttng_consumer_global_data consumer_data; extern int consumer_poll_timeout; @@ -82,6 +81,7 @@ static void destroy_channel(struct lttng_consumer_channel *channel) */ if (channel->uchan) { lttng_ustconsumer_del_channel(channel); + lttng_ustconsumer_free_channel(channel); } free(channel); } @@ -247,14 +247,14 @@ error: static int get_stream_shm_path(char *stream_shm_path, const char *shm_path, int cpu) { - char cpu_nr[UINT_MAX_STR_LEN]; /* unsigned int max len */ + char cpu_nr[INT_MAX_STR_LEN]; /* int max len */ int ret; strncpy(stream_shm_path, shm_path, PATH_MAX); stream_shm_path[PATH_MAX - 1] = '\0'; - ret = snprintf(cpu_nr, UINT_MAX_STR_LEN, "%u", cpu); - if (ret != 1) { - ret = -1; + ret = snprintf(cpu_nr, INT_MAX_STR_LEN, "%i", cpu); + if (ret < 0) { + PERROR("snprintf"); goto end; } strncat(stream_shm_path, cpu_nr, @@ -1830,8 +1830,6 @@ void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan) if (chan->switch_timer_enabled == 1) { consumer_timer_switch_stop(chan); } - consumer_metadata_cache_destroy(chan); - ustctl_destroy_channel(chan->uchan); for (i = 0; i < chan->nr_stream_fds; i++) { int ret; @@ -1852,7 +1850,6 @@ void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan) } } } - free(chan->stream_fds); /* Try to rmdir all directories under shm_path root. */ if (chan->root_shm_path[0]) { (void) run_as_recursive_rmdir(chan->root_shm_path, @@ -1860,6 +1857,16 @@ void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan) } } +void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan) +{ + assert(chan); + assert(chan->uchan); + + consumer_metadata_cache_destroy(chan); + ustctl_destroy_channel(chan->uchan); + free(chan->stream_fds); +} + void lttng_ustconsumer_del_stream(struct lttng_consumer_stream *stream) { assert(stream);