X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-app.c;h=56860d714e3a6e5a605e75c56a1fb200037fd1bb;hp=e01d43caf024ec61f3311ad323c4d3f7254afade;hb=3b9677124ab48bddc945ca67947c49b87b5853e0;hpb=348a81dcf7b6944b10a813d93dcaf86fdb5194f6 diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index e01d43caf..56860d714 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1832,15 +1832,12 @@ static void shadow_copy_channel(struct ust_app_channel *ua_chan, static void shadow_copy_session(struct ust_app_session *ua_sess, struct ltt_ust_session *usess, struct ust_app *app) { - time_t rawtime; struct tm *timeinfo; char datetime[16]; int ret; char tmp_shm_path[PATH_MAX]; - /* Get date and time for unique app path */ - time(&rawtime); - timeinfo = localtime(&rawtime); + timeinfo = localtime(&app->registration_time); strftime(datetime, sizeof(datetime), "%Y%m%d-%H%M%S", timeinfo); DBG2("Shadow copy of session handle %d", ua_sess->handle); @@ -3377,6 +3374,8 @@ void ust_app_add(struct ust_app *app) assert(app); assert(app->notify_sock >= 0); + app->registration_time = time(NULL); + rcu_read_lock(); /* @@ -5884,7 +5883,6 @@ enum lttng_error_code ust_app_snapshot_record( enum lttng_error_code status = LTTNG_OK; struct lttng_ht_iter iter; struct ust_app *app; - char pathname[PATH_MAX]; assert(usess); assert(output); @@ -5899,6 +5897,8 @@ enum lttng_error_code ust_app_snapshot_record( cds_list_for_each_entry(reg, &usess->buffer_reg_uid_list, lnode) { struct buffer_reg_channel *reg_chan; struct consumer_socket *socket; + char *trace_path = NULL; + char pathname[PATH_MAX]; if (!reg->registry->reg.ust->metadata_key) { /* Skip since no metadata is present */ @@ -5926,22 +5926,28 @@ enum lttng_error_code ust_app_snapshot_record( status = LTTNG_ERR_INVALID; goto error; } - + trace_path = setup_channel_trace_path(usess->consumer, pathname); + if (!trace_path) { + status = LTTNG_ERR_INVALID; + goto error; + } /* Add the UST default trace dir to path. */ cds_lfht_for_each_entry(reg->registry->channels->ht, &iter.iter, reg_chan, node.node) { status = consumer_snapshot_channel(socket, reg_chan->consumer_key, output, 0, usess->uid, - usess->gid, pathname, wait, + usess->gid, trace_path, wait, nb_packets_per_stream); if (status != LTTNG_OK) { + free(trace_path); goto error; } } status = consumer_snapshot_channel(socket, reg->registry->reg.ust->metadata_key, output, 1, - usess->uid, usess->gid, pathname, wait, 0); + usess->uid, usess->gid, trace_path, wait, 0); + free(trace_path); if (status != LTTNG_OK) { goto error; } @@ -5956,6 +5962,8 @@ enum lttng_error_code ust_app_snapshot_record( struct ust_app_channel *ua_chan; struct ust_app_session *ua_sess; struct ust_registry_session *registry; + char *trace_path = NULL; + char pathname[PATH_MAX]; ua_sess = lookup_session_by_app(usess, app); if (!ua_sess) { @@ -5980,7 +5988,11 @@ enum lttng_error_code ust_app_snapshot_record( PERROR("snprintf snapshot path"); goto error; } - + trace_path = setup_channel_trace_path(usess->consumer, pathname); + if (!trace_path) { + status = LTTNG_ERR_INVALID; + goto error; + } cds_lfht_for_each_entry(ua_sess->channels->ht, &chan_iter.iter, ua_chan, node.node) { status = consumer_snapshot_channel(socket, @@ -5989,14 +6001,16 @@ enum lttng_error_code ust_app_snapshot_record( .uid, ua_sess->effective_credentials .gid, - pathname, wait, + trace_path, wait, nb_packets_per_stream); switch (status) { case LTTNG_OK: break; case LTTNG_ERR_CHAN_NOT_FOUND: + free(trace_path); continue; default: + free(trace_path); goto error; } } @@ -6010,7 +6024,8 @@ enum lttng_error_code ust_app_snapshot_record( registry->metadata_key, output, 1, ua_sess->effective_credentials.uid, ua_sess->effective_credentials.gid, - pathname, wait, 0); + trace_path, wait, 0); + free(trace_path); switch (status) { case LTTNG_OK: break;