return new_chunk;
error_unlock:
pthread_mutex_unlock(&source_chunk->lock);
+ lttng_trace_chunk_put(new_chunk);
return NULL;
}
chunk->credentials.value.use_current_user ?
NULL : &chunk->credentials.value.user);
if (ret < 0) {
- ERR("Failed to open file relative to trace chunk file_path = \"%s\", flags = %d, mode = %d",
+ PERROR("Failed to open file relative to trace chunk file_path = \"%s\", flags = %d, mode = %d",
file_path, flags, (int) mode);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
creation_timestamp, NULL);
if (!directory_to_rename) {
ERR("Failed to generate initial trace chunk name while renaming trace chunk");
+ goto end;
}
free_directory_to_rename = true;
}
*
* Re-attempt to publish.
*/
- ERR("Attemp to publish a trace chunk to the chunk registry raced with a trace chunk deletion");
+ ERR("Attempt to publish a trace chunk to the chunk registry raced with a trace chunk deletion");
continue;
}
}
session_id, &chunk_id);
}
+LTTNG_HIDDEN
+int lttng_trace_chunk_registry_chunk_exists(
+ const struct lttng_trace_chunk_registry *registry,
+ uint64_t session_id, uint64_t chunk_id, bool *chunk_exists)
+{
+ int ret = 0;
+ const struct lttng_trace_chunk_registry_element target_element = {
+ .chunk.id.is_set = true,
+ .chunk.id.value = chunk_id,
+ .session_id = session_id,
+ };
+ const unsigned long element_hash =
+ lttng_trace_chunk_registry_element_hash(
+ &target_element);
+ struct cds_lfht_node *published_node;
+ struct cds_lfht_iter iter;
+
+ rcu_read_lock();
+ cds_lfht_lookup(registry->ht,
+ element_hash,
+ lttng_trace_chunk_registry_element_match,
+ &target_element,
+ &iter);
+ published_node = cds_lfht_iter_get_node(&iter);
+ if (!published_node) {
+ *chunk_exists = false;
+ goto end;
+ }
+
+ *chunk_exists = !cds_lfht_is_node_deleted(published_node);
+end:
+ rcu_read_unlock();
+ return ret;
+}
+
LTTNG_HIDDEN
struct lttng_trace_chunk *
lttng_trace_chunk_registry_find_anonymous_chunk(