X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-app.c;h=f6f2c64ae9895958af62592b15cccee9b42527ff;hp=374360e48c365937a20952e6623e356e21fae41c;hb=37f1c23617e54ba79c11ff6dc4c4ce7ad07f7be9;hpb=7f13370536e1ad64db733423b542755c97160f4d diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 374360e48..f6f2c64ae 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -155,7 +155,7 @@ void delete_ust_app_event(int sock, struct ust_app_event *ua_event) * this function. */ static -void delete_ust_app_stream(int sock, struct ltt_ust_stream *stream) +void delete_ust_app_stream(int sock, struct ust_app_stream *stream) { if (stream->obj) { ustctl_release_object(sock, stream->obj); @@ -176,7 +176,7 @@ void delete_ust_app_channel(int sock, struct ust_app_channel *ua_chan) struct lttng_ht_iter iter; struct ust_app_event *ua_event; struct ust_app_ctx *ua_ctx; - struct ltt_ust_stream *stream, *stmp; + struct ust_app_stream *stream, *stmp; /* Wipe stream */ cds_list_for_each_entry_safe(stream, stmp, &ua_chan->streams.head, list) { @@ -378,6 +378,28 @@ error: return NULL; } +/* + * Allocate and initialize a UST app stream. + * + * Return newly allocated stream pointer or NULL on error. + */ +static struct ust_app_stream *alloc_ust_app_stream(void) +{ + struct ust_app_stream *stream = NULL; + + stream = zmalloc(sizeof(*stream)); + if (stream == NULL) { + PERROR("zmalloc ust app stream"); + goto error; + } + + /* Zero could be a valid value for a handle so flag it to -1. */ + stream->handle = -1; + +error: + return stream; +} + /* * Alloc new UST app event. */ @@ -757,7 +779,7 @@ error: * On error, return a negative value. */ static int create_ust_stream(struct ust_app *app, - struct ust_app_channel *ua_chan, struct ltt_ust_stream *stream) + struct ust_app_channel *ua_chan, struct ust_app_stream *stream) { int ret; @@ -2314,7 +2336,7 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) struct lttng_ht_iter iter; struct ust_app_session *ua_sess; struct ust_app_channel *ua_chan; - struct ltt_ust_stream *ustream; + struct ust_app_stream *ustream; struct consumer_socket *socket; DBG("Starting tracing for ust app pid %d", app->pid); @@ -2362,9 +2384,8 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) /* Create all streams */ while (1) { /* Create UST stream */ - ustream = zmalloc(sizeof(*ustream)); + ustream = alloc_ust_app_stream(); if (ustream == NULL) { - PERROR("zmalloc ust stream"); goto error_rcu_unlock; }