- cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct((void *) stream->path_name, lttng_ht_seed),
- ht->match_fct, (void *) stream->path_name,
- &iter.iter, tmp_stream, ctf_trace_node.node) {
- if (stream->metadata_flag) {
- /*
- * The new stream is the metadata stream for this trace,
- * assign the ctf_trace pointer to all the streams in
- * this bucket.
- */
- pthread_mutex_lock(&tmp_stream->lock);
- tmp_stream->ctf_trace = stream->ctf_trace;
- uatomic_inc(&tmp_stream->ctf_trace->refcount);
- pthread_mutex_unlock(&tmp_stream->lock);
- DBG("Assigned ctf_trace %" PRIu64 " to stream %" PRIu64,
- tmp_stream->ctf_trace->id, tmp_stream->stream_handle);
- } else if (tmp_stream->ctf_trace) {
- /*
- * The ctf_trace already exists for this bucket,
- * just assign the pointer to the new stream and exit.
- */
- stream->ctf_trace = tmp_stream->ctf_trace;
- uatomic_inc(&stream->ctf_trace->refcount);
- DBG("Assigned ctf_trace %" PRIu64 " to stream %" PRIu64,
- tmp_stream->ctf_trace->id, tmp_stream->stream_handle);
- goto end;
- } else {
- /*
- * We don't know yet the ctf_trace ID (no metadata has been added),
- * so leave it there until the metadata stream arrives.
- */
- goto end;
- }