X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-app.c;h=8b3028c57201f98ffdefe19ded346b9956399b4c;hb=d7912dd1d4af8e8f0e92b2479a2de73f9da0fd11;hp=59d8a8fc49a96edf8327e85ea033879555e87487;hpb=88e3c2f5610b9ac89b0923d448fee34140fc46fb;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 59d8a8fc4..8b3028c57 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1831,15 +1831,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); @@ -1993,7 +1990,7 @@ static int setup_buffer_reg_pid(struct ust_app_session *ua_sess, app->byte_order, app->version.major, app->version.minor, reg_pid->root_shm_path, reg_pid->shm_path, - ua_sess->euid, ua_sess->egid); + ua_sess->euid, ua_sess->egid, ua_sess->tracing_id, app->uid); if (ret < 0) { /* * reg_pid->registry->reg.ust is NULL upon error, so we need to @@ -2060,7 +2057,8 @@ static int setup_buffer_reg_uid(struct ltt_ust_session *usess, app->uint64_t_alignment, app->long_alignment, app->byte_order, app->version.major, app->version.minor, reg_uid->root_shm_path, - reg_uid->shm_path, usess->uid, usess->gid); + reg_uid->shm_path, usess->uid, usess->gid, + ua_sess->tracing_id, app->uid); if (ret < 0) { /* * reg_uid->registry->reg.ust is NULL upon error, so we need to @@ -3376,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(); /* @@ -4402,24 +4402,18 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) /* Create directories if consumer is LOCAL and has a path defined. */ if (usess->consumer->type == CONSUMER_DST_LOCAL && usess->consumer->dst.session_root_path[0] != '\0') { - char *tmp_path; + char tmp_path[LTTNG_PATH_MAX]; - tmp_path = zmalloc(LTTNG_PATH_MAX); - if (!tmp_path) { - ERR("Alloc tmp_path"); - goto error_unlock; - } - ret = snprintf(tmp_path, LTTNG_PATH_MAX, "%s%s%s", + ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s%s", usess->consumer->dst.session_root_path, usess->consumer->chunk_path, - usess->consumer->subdir); - if (ret >= LTTNG_PATH_MAX) { - ERR("Local destination path exceeds the maximal allowed length of %i bytes (needs %i bytes) with path = \"%s%s%s\"", - LTTNG_PATH_MAX, ret, + usess->consumer->domain_subdir); + if (ret >= sizeof(tmp_path)) { + ERR("Local destination path exceeds the maximal allowed length of %zu bytes (needs %i bytes) with path = \"%s%s%s\"", + sizeof(tmp_path), ret, usess->consumer->dst.session_root_path, usess->consumer->chunk_path, - usess->consumer->subdir); - free(tmp_path); + usess->consumer->domain_subdir); goto error_unlock; } @@ -4427,7 +4421,6 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) tmp_path); ret = run_as_mkdir_recursive(tmp_path, S_IRWXU | S_IRWXG, ua_sess->euid, ua_sess->egid); - free(tmp_path); if (ret < 0) { if (errno != EEXIST) { ERR("Trace directory creation error"); @@ -6343,7 +6336,7 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session) ret = snprintf(pathname, sizeof(pathname), DEFAULT_UST_TRACE_DIR "/" DEFAULT_UST_TRACE_UID_PATH, reg->uid, reg->bits_per_long); - if (ret < 0 || ret == sizeof(pathname)) { + if (ret < 0 || ret >= sizeof(pathname)) { PERROR("Failed to format rotation path"); cmd_ret = LTTNG_ERR_INVALID; goto error; @@ -6396,7 +6389,7 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session) ret = snprintf(pathname, sizeof(pathname), DEFAULT_UST_TRACE_DIR "/%s", ua_sess->path); - if (ret < 0 || ret == sizeof(pathname)) { + if (ret < 0 || ret >= sizeof(pathname)) { PERROR("Failed to format rotation path"); cmd_ret = LTTNG_ERR_INVALID; goto error;