- pthread_mutex_lock(&session->lock);
- ret = asprintf(&session_directory, "%s/%s-%s", session->hostname,
- session->session_name, creation_time_str);
- pthread_mutex_unlock(&session->lock);
+ assert(session->creation_time.is_set);
+ timeinfo = localtime(&session->creation_time.value);
+ if (!timeinfo) {
+ ret = -1;
+ goto end;
+ }
+ strftime(creation_time_str, sizeof(creation_time_str), "%Y%m%d-%H%M%S",
+ timeinfo);
+
+ pthread_mutex_lock(&session->lock);
+ ret = asprintf(&session_directory, "%s/%s-%s", session->hostname,
+ session->session_name, creation_time_str);
+ pthread_mutex_unlock(&session->lock);
+ } else {
+ pthread_mutex_lock(&session->lock);
+ ret = asprintf(&session_directory, "%s/%s", session->hostname,
+ session->base_path);
+ pthread_mutex_unlock(&session->lock);
+ }