projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: sessiond: crash enabling event rules that differ only by loglevel type
[lttng-tools.git]
/
src
/
bin
/
lttng-relayd
/
ctf-trace.cpp
diff --git
a/src/bin/lttng-relayd/ctf-trace.cpp
b/src/bin/lttng-relayd/ctf-trace.cpp
index 861bcfbb3f7a44c6d055babdc544abc584835dfc..cde9f3927e381297b3f3b8bd53a00532ea2f2e98 100644
(file)
--- a/
src/bin/lttng-relayd/ctf-trace.cpp
+++ b/
src/bin/lttng-relayd/ctf-trace.cpp
@@
-9,21
+9,22
@@
#define _LGPL_SOURCE
#define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/utils.h>
-#include <urcu/rculist.h>
+#include "ctf-trace.hpp"
+#include "lttng-relayd.hpp"
+#include "stream.hpp"
+
+#include <common/common.hpp>
+#include <common/urcu.hpp>
+#include <common/utils.hpp>
-#include "ctf-trace.h"
-#include "lttng-relayd.h"
-#include "stream.h"
+#include <urcu/rculist.h>
static uint64_t last_relay_ctf_trace_id;
static pthread_mutex_t last_relay_ctf_trace_id_lock = PTHREAD_MUTEX_INITIALIZER;
static void rcu_destroy_ctf_trace(struct rcu_head *rcu_head)
{
static uint64_t last_relay_ctf_trace_id;
static pthread_mutex_t last_relay_ctf_trace_id_lock = PTHREAD_MUTEX_INITIALIZER;
static void rcu_destroy_ctf_trace(struct rcu_head *rcu_head)
{
- struct ctf_trace *trace =
- caa_container_of(rcu_head, struct ctf_trace, rcu_node);
+ struct ctf_trace *trace = lttng::utils::container_of(rcu_head, &ctf_trace::rcu_node);
free(trace);
}
free(trace);
}
@@
-44,16
+45,15
@@
static void ctf_trace_destroy(struct ctf_trace *trace)
ASSERT_RCU_READ_LOCKED();
session_put(trace->session);
ASSERT_RCU_READ_LOCKED();
session_put(trace->session);
- trace->session =
NULL
;
+ trace->session =
nullptr
;
free(trace->path);
free(trace->path);
- trace->path =
NULL
;
+ trace->path =
nullptr
;
call_rcu(&trace->rcu_node, rcu_destroy_ctf_trace);
}
static void ctf_trace_release(struct urcu_ref *ref)
{
call_rcu(&trace->rcu_node, rcu_destroy_ctf_trace);
}
static void ctf_trace_release(struct urcu_ref *ref)
{
- struct ctf_trace *trace =
- caa_container_of(ref, struct ctf_trace, ref);
+ struct ctf_trace *trace = lttng::utils::container_of(ref, &ctf_trace::ref);
int ret;
struct lttng_ht_iter iter;
int ret;
struct lttng_ht_iter iter;
@@
-92,12
+92,11
@@
bool ctf_trace_get(struct ctf_trace *trace)
* create and refcounting. Whenever all the streams belonging to a trace
* put their reference, its refcount drops to 0.
*/
* create and refcounting. Whenever all the streams belonging to a trace
* put their reference, its refcount drops to 0.
*/
-static struct ctf_trace *ctf_trace_create(struct relay_session *session,
- const char *subpath)
+static struct ctf_trace *ctf_trace_create(struct relay_session *session, const char *subpath)
{
struct ctf_trace *trace;
{
struct ctf_trace *trace;
- trace =
(ctf_trace *) zmalloc(sizeof(*trace)
);
+ trace =
zmalloc<ctf_trace>(
);
if (!trace) {
PERROR("Failed to allocate ctf_trace");
goto end;
if (!trace) {
PERROR("Failed to allocate ctf_trace");
goto end;
@@
-122,19
+121,21
@@
static struct ctf_trace *ctf_trace_create(struct relay_session *session,
lttng_ht_node_init_str(&trace->node, trace->path);
trace->session = session;
lttng_ht_node_init_str(&trace->node, trace->path);
trace->session = session;
- pthread_mutex_init(&trace->lock,
NULL
);
- pthread_mutex_init(&trace->stream_list_lock,
NULL
);
+ pthread_mutex_init(&trace->lock,
nullptr
);
+ pthread_mutex_init(&trace->stream_list_lock,
nullptr
);
lttng_ht_add_str(session->ctf_traces_ht, &trace->node);
lttng_ht_add_str(session->ctf_traces_ht, &trace->node);
- DBG("Created ctf_trace %" PRIu64 "of session \"%s\" from host \"%s\" with path: %s",
- trace->id, session->session_name, session->hostname,
- subpath);
+ DBG("Created ctf_trace %" PRIu64 " of session \"%s\" from host \"%s\" with path: %s",
+ trace->id,
+ session->session_name,
+ session->hostname,
+ subpath);
end:
return trace;
error:
ctf_trace_put(trace);
end:
return trace;
error:
ctf_trace_put(trace);
- return
NULL
;
+ return
nullptr
;
}
/*
}
/*
@@
-143,25
+144,24
@@
error:
* ctf_trace_put().
*/
struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session,
* ctf_trace_put().
*/
struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session,
- const char *subpath)
+
const char *subpath)
{
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
{
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
- struct ctf_trace *trace =
NULL
;
+ struct ctf_trace *trace =
nullptr
;
-
rcu_read_lock()
;
+
lttng::urcu::read_lock_guard read_lock
;
lttng_ht_lookup(session->ctf_traces_ht, subpath, &iter);
node = lttng_ht_iter_get_node_str(&iter);
if (!node) {
DBG("CTF Trace path %s not found", subpath);
goto end;
}
lttng_ht_lookup(session->ctf_traces_ht, subpath, &iter);
node = lttng_ht_iter_get_node_str(&iter);
if (!node) {
DBG("CTF Trace path %s not found", subpath);
goto end;
}
- trace =
caa_container_of(node, struct ctf_trace,
node);
+ trace =
lttng::utils::container_of(node, &ctf_trace::
node);
if (!ctf_trace_get(trace)) {
if (!ctf_trace_get(trace)) {
- trace =
NULL
;
+ trace =
nullptr
;
}
end:
}
end:
- rcu_read_unlock();
if (!trace) {
/* Try to create */
trace = ctf_trace_create(session, subpath);
if (!trace) {
/* Try to create */
trace = ctf_trace_create(session, subpath);
@@
-171,25
+171,23
@@
end:
void ctf_trace_put(struct ctf_trace *trace)
{
void ctf_trace_put(struct ctf_trace *trace)
{
-
rcu_read_lock()
;
+
lttng::urcu::read_lock_guard read_lock
;
urcu_ref_put(&trace->ref, ctf_trace_release);
urcu_ref_put(&trace->ref, ctf_trace_release);
- rcu_read_unlock();
}
int ctf_trace_close(struct ctf_trace *trace)
{
struct relay_stream *stream;
}
int ctf_trace_close(struct ctf_trace *trace)
{
struct relay_stream *stream;
-
rcu_read_lock()
;
- cds_list_for_each_entry_rcu(stream, &trace->stream_list,
-
stream_node)
{
+
lttng::urcu::read_lock_guard read_lock
;
+ cds_list_for_each_entry_rcu(stream, &trace->stream_list,
stream_node)
+ {
/*
* Close stream since the connection owning the trace is being
* torn down.
*/
try_stream_close(stream);
}
/*
* Close stream since the connection owning the trace is being
* torn down.
*/
try_stream_close(stream);
}
- rcu_read_unlock();
/*
* Since all references to the trace are held by its streams, we
* don't need to do any self-ref put.
/*
* Since all references to the trace are held by its streams, we
* don't need to do any self-ref put.
@@
-201,15
+199,14
@@
struct relay_viewer_stream *ctf_trace_get_viewer_metadata_stream(struct ctf_trac
{
struct relay_viewer_stream *vstream;
{
struct relay_viewer_stream *vstream;
-
rcu_read_lock()
;
+
lttng::urcu::read_lock_guard read_lock
;
vstream = rcu_dereference(trace->viewer_metadata_stream);
if (!vstream) {
goto end;
}
if (!viewer_stream_get(vstream)) {
vstream = rcu_dereference(trace->viewer_metadata_stream);
if (!vstream) {
goto end;
}
if (!viewer_stream_get(vstream)) {
- vstream =
NULL
;
+ vstream =
nullptr
;
}
end:
}
end:
- rcu_read_unlock();
return vstream;
}
return vstream;
}
This page took
0.025855 seconds
and
4
git commands to generate.