#include <common/common.hpp>
#include <common/compat/string.hpp>
#include <common/index/index.hpp>
+#include <common/urcu.hpp>
#include <common/utils.hpp>
#include <algorithm>
{
if (vstream->stream_file.handle) {
fs_handle_close(vstream->stream_file.handle);
- vstream->stream_file.handle = NULL;
+ vstream->stream_file.handle = nullptr;
}
if (vstream->index_file) {
lttng_index_file_put(vstream->index_file);
- vstream->index_file = NULL;
+ vstream->index_file = nullptr;
}
if (vstream->stream) {
stream_put(vstream->stream);
- vstream->stream = NULL;
+ vstream->stream = nullptr;
}
lttng_trace_chunk_put(vstream->stream_file.trace_chunk);
- vstream->stream_file.trace_chunk = NULL;
+ vstream->stream_file.trace_chunk = nullptr;
}
static void viewer_stream_destroy(struct relay_viewer_stream *vstream)
struct lttng_trace_chunk *trace_chunk,
enum lttng_viewer_seek seek_t)
{
- struct relay_viewer_stream *vstream = NULL;
+ struct relay_viewer_stream *vstream = nullptr;
ASSERT_LOCKED(stream->lock);
vstream->stream_file.trace_chunk = trace_chunk;
vstream->path_name = lttng_strndup(stream->path_name, LTTNG_VIEWER_PATH_MAX);
- if (vstream->path_name == NULL) {
+ if (vstream->path_name == nullptr) {
PERROR("relay viewer path_name alloc");
goto error;
}
vstream->channel_name = lttng_strndup(stream->channel_name, LTTNG_VIEWER_NAME_MAX);
- if (vstream->channel_name == NULL) {
+ if (vstream->channel_name == nullptr) {
PERROR("relay viewer channel_name alloc");
goto error;
}
* If we never received an index for the current stream, delay
* the opening of the index, otherwise open it right now.
*/
- if (stream->index_file == NULL) {
- vstream->index_file = NULL;
+ if (stream->index_file == nullptr) {
+ vstream->index_file = nullptr;
} else if (vstream->stream_file.trace_chunk) {
const uint32_t connection_major = stream->trace->session->major;
const uint32_t connection_minor = stream->trace->session->minor;
&vstream->index_file);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
if (chunk_status == LTTNG_TRACE_CHUNK_STATUS_NO_FILE) {
- vstream->index_file = NULL;
+ vstream->index_file = nullptr;
} else {
goto error;
}
stream->channel_name,
stream->tracefile_size,
vstream->current_tracefile_id,
- NULL,
+ nullptr,
file_path,
sizeof(file_path));
if (ret < 0) {
viewer_stream_release_composite_objects(vstream);
viewer_stream_destroy(vstream);
}
- return NULL;
+ return nullptr;
}
static void viewer_stream_unpublish(struct relay_viewer_stream *vstream)
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
- struct relay_viewer_stream *vstream = NULL;
+ struct relay_viewer_stream *vstream = nullptr;
- rcu_read_lock();
+ lttng::urcu::read_lock_guard read_lock;
lttng_ht_lookup(viewer_streams_ht, &id, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
if (!node) {
}
vstream = lttng::utils::container_of(node, &relay_viewer_stream::stream_n);
if (!viewer_stream_get(vstream)) {
- vstream = NULL;
+ vstream = nullptr;
}
end:
- rcu_read_unlock();
return vstream;
}
void viewer_stream_put(struct relay_viewer_stream *vstream)
{
- rcu_read_lock();
+ lttng::urcu::read_lock_guard read_lock;
urcu_ref_put(&vstream->ref, viewer_stream_release);
- rcu_read_unlock();
}
void viewer_stream_close_files(struct relay_viewer_stream *vstream)
{
if (vstream->index_file) {
lttng_index_file_put(vstream->index_file);
- vstream->index_file = NULL;
+ vstream->index_file = nullptr;
}
if (vstream->stream_file.handle) {
fs_handle_close(vstream->stream_file.handle);
- vstream->stream_file.handle = NULL;
+ vstream->stream_file.handle = nullptr;
}
}
return ret;
}
-void print_viewer_streams(void)
+void print_viewer_streams()
{
struct lttng_ht_iter iter;
struct relay_viewer_stream *vstream;
return;
}
- rcu_read_lock();
- cds_lfht_for_each_entry (viewer_streams_ht->ht, &iter.iter, vstream, stream_n.node) {
- if (!viewer_stream_get(vstream)) {
- continue;
+ {
+ lttng::urcu::read_lock_guard read_lock;
+
+ cds_lfht_for_each_entry (
+ viewer_streams_ht->ht, &iter.iter, vstream, stream_n.node) {
+ if (!viewer_stream_get(vstream)) {
+ continue;
+ }
+ DBG("vstream %p refcount %ld stream %" PRIu64 " trace %" PRIu64
+ " session %" PRIu64,
+ vstream,
+ vstream->ref.refcount,
+ vstream->stream->stream_handle,
+ vstream->stream->trace->id,
+ vstream->stream->trace->session->id);
+ viewer_stream_put(vstream);
}
- DBG("vstream %p refcount %ld stream %" PRIu64 " trace %" PRIu64 " session %" PRIu64,
- vstream,
- vstream->ref.refcount,
- vstream->stream->stream_handle,
- vstream->stream->trace->id,
- vstream->stream->trace->session->id);
- viewer_stream_put(vstream);
}
- rcu_read_unlock();
}