projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: ini parser: truncation of value name
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
tracker.cpp
diff --git
a/src/bin/lttng-sessiond/tracker.cpp
b/src/bin/lttng-sessiond/tracker.cpp
index 204ade426316b288afd6e59d1ceade61f82a706f..9e1a155adcdefb2b71fc7f478677f30521265afa 100644
(file)
--- a/
src/bin/lttng-sessiond/tracker.cpp
+++ b/
src/bin/lttng-sessiond/tracker.cpp
@@
-6,10
+6,20
@@
*
*/
*
*/
-#include "lttng/tracker.h"
#include "common/dynamic-array.hpp"
#include "common/macros.hpp"
#include "common/dynamic-array.hpp"
#include "common/macros.hpp"
+#include "lttng/tracker.h"
#define _LGPL_SOURCE
#define _LGPL_SOURCE
+#include "tracker.hpp"
+
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/tracker.hpp>
+
+#include <lttng/lttng-error.h>
+
#include <grp.h>
#include <pwd.h>
#include <sys/types.h>
#include <grp.h>
#include <pwd.h>
#include <sys/types.h>
@@
-18,47
+28,40
@@
#include <urcu/list.h>
#include <urcu/rculfhash.h>
#include <urcu/list.h>
#include <urcu/rculfhash.h>
-#include "tracker.hpp"
-#include <common/defaults.hpp>
-#include <common/error.hpp>
-#include <common/hashtable/hashtable.hpp>
-#include <common/hashtable/utils.hpp>
-#include <common/tracker.hpp>
-#include <lttng/lttng-error.h>
+struct process_attr_tracker {
+ enum lttng_tracking_policy policy;
+ struct cds_lfht *inclusion_set_ht;
+};
+namespace {
struct process_attr_tracker_value_node {
struct process_attr_value *value;
struct cds_lfht_node inclusion_set_ht_node;
struct rcu_head rcu_head;
};
struct process_attr_tracker_value_node {
struct process_attr_value *value;
struct cds_lfht_node inclusion_set_ht_node;
struct rcu_head rcu_head;
};
-
-struct process_attr_tracker {
- enum lttng_tracking_policy policy;
- struct cds_lfht *inclusion_set_ht;
-};
+} /* namespace */
static void process_attr_tracker_value_node_rcu_free(struct rcu_head *rcu_head)
{
struct process_attr_tracker_value_node *node =
static void process_attr_tracker_value_node_rcu_free(struct rcu_head *rcu_head)
{
struct process_attr_tracker_value_node *node =
-
container_of(rcu_head, typeof(*node),
rcu_head);
+
lttng::utils::container_of(rcu_head, &process_attr_tracker_value_node::
rcu_head);
free(node);
}
free(node);
}
-struct process_attr_tracker *process_attr_tracker_create(
void
)
+struct process_attr_tracker *process_attr_tracker_create()
{
struct process_attr_tracker *tracker;
{
struct process_attr_tracker *tracker;
- tracker =
(process_attr_tracker *) zmalloc(sizeof(*tracker)
);
+ tracker =
zmalloc<process_attr_tracker>(
);
if (!tracker) {
if (!tracker) {
- return
NULL
;
+ return
nullptr
;
}
}
- (void) process_attr_tracker_set_tracking_policy(
- tracker, LTTNG_TRACKING_POLICY_INCLUDE_ALL);
+ (void) process_attr_tracker_set_tracking_policy(tracker, LTTNG_TRACKING_POLICY_INCLUDE_ALL);
- tracker->inclusion_set_ht = cds_lfht_new(
DEFAULT_HT_SIZE, 1, 0,
-
CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL
);
+ tracker->inclusion_set_ht = cds_lfht_new(
+
DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr
);
if (!tracker->inclusion_set_ht) {
goto error;
}
if (!tracker->inclusion_set_ht) {
goto error;
}
@@
-66,22
+69,19
@@
struct process_attr_tracker *process_attr_tracker_create(void)
return tracker;
error:
process_attr_tracker_destroy(tracker);
return tracker;
error:
process_attr_tracker_destroy(tracker);
- return
NULL
;
+ return
nullptr
;
}
}
-static void
process_attr_tracker_remove_value_node(
-
struct process_attr_tracker *tracker,
- struct process_attr_tracker_value_node *value_node)
+static void
+
process_attr_tracker_remove_value_node(
struct process_attr_tracker *tracker,
+
struct process_attr_tracker_value_node *value_node)
{
{
- cds_lfht_del(tracker->inclusion_set_ht,
- &value_node->inclusion_set_ht_node);
+ cds_lfht_del(tracker->inclusion_set_ht, &value_node->inclusion_set_ht_node);
process_attr_value_destroy(value_node->value);
process_attr_value_destroy(value_node->value);
- call_rcu(&value_node->rcu_head,
- process_attr_tracker_value_node_rcu_free);
+ call_rcu(&value_node->rcu_head, process_attr_tracker_value_node_rcu_free);
}
}
-static void process_attr_tracker_clear_inclusion_set(
- struct process_attr_tracker *tracker)
+static void process_attr_tracker_clear_inclusion_set(struct process_attr_tracker *tracker)
{
int ret;
struct lttng_ht_iter iter;
{
int ret;
struct lttng_ht_iter iter;
@@
-92,22
+92,21
@@
static void process_attr_tracker_clear_inclusion_set(
}
rcu_read_lock();
}
rcu_read_lock();
- cds_lfht_for_each_entry (
tracker->inclusion_set_ht, &iter.iter,
-
value_node, inclusion_set_ht_node) {
+ cds_lfht_for_each_entry (
+
tracker->inclusion_set_ht, &iter.iter,
value_node, inclusion_set_ht_node) {
process_attr_tracker_remove_value_node(tracker, value_node);
}
rcu_read_unlock();
process_attr_tracker_remove_value_node(tracker, value_node);
}
rcu_read_unlock();
- ret = cds_lfht_destroy(tracker->inclusion_set_ht,
NULL
);
+ ret = cds_lfht_destroy(tracker->inclusion_set_ht,
nullptr
);
LTTNG_ASSERT(ret == 0);
LTTNG_ASSERT(ret == 0);
- tracker->inclusion_set_ht =
NULL
;
+ tracker->inclusion_set_ht =
nullptr
;
}
}
-static int process_attr_tracker_create_inclusion_set(
- struct process_attr_tracker *tracker)
+static int process_attr_tracker_create_inclusion_set(struct process_attr_tracker *tracker)
{
LTTNG_ASSERT(!tracker->inclusion_set_ht);
{
LTTNG_ASSERT(!tracker->inclusion_set_ht);
- tracker->inclusion_set_ht = cds_lfht_new(
DEFAULT_HT_SIZE, 1, 0,
-
CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL
);
+ tracker->inclusion_set_ht = cds_lfht_new(
+
DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr
);
return tracker->inclusion_set_ht ? 0 : -1;
}
return tracker->inclusion_set_ht ? 0 : -1;
}
@@
-121,15
+120,14
@@
void process_attr_tracker_destroy(struct process_attr_tracker *tracker)
free(tracker);
}
free(tracker);
}
-enum lttng_tracking_policy
process_attr_tracker_get_tracking_policy(
-
const struct process_attr_tracker *tracker)
+enum lttng_tracking_policy
+
process_attr_tracker_get_tracking_policy(
const struct process_attr_tracker *tracker)
{
return tracker->policy;
}
{
return tracker->policy;
}
-int process_attr_tracker_set_tracking_policy(
- struct process_attr_tracker *tracker,
- enum lttng_tracking_policy tracking_policy)
+int process_attr_tracker_set_tracking_policy(struct process_attr_tracker *tracker,
+ enum lttng_tracking_policy tracking_policy)
{
int ret = 0;
{
int ret = 0;
@@
-147,21
+145,18
@@
end:
return ret;
}
return ret;
}
-static int match_inclusion_set_value(
- struct cds_lfht_node *node, const void *key)
+static int match_inclusion_set_value(struct cds_lfht_node *node, const void *key)
{
const struct process_attr_value *value_key = (process_attr_value *) key;
{
const struct process_attr_value *value_key = (process_attr_value *) key;
- const struct process_attr_tracker_value_node *value_node =
- caa_container_of(node,
- struct process_attr_tracker_value_node,
- inclusion_set_ht_node);
+ const struct process_attr_tracker_value_node *value_node = caa_container_of(
+ node, struct process_attr_tracker_value_node, inclusion_set_ht_node);
return process_attr_tracker_value_equal(value_node->value, value_key);
}
return process_attr_tracker_value_equal(value_node->value, value_key);
}
-static struct process_attr_tracker_value_node *
process_attr_tracker_lookup(
-
const struct process_attr_tracker *tracker,
- const struct process_attr_value *value)
+static struct process_attr_tracker_value_node *
+
process_attr_tracker_lookup(
const struct process_attr_tracker *tracker,
+
const struct process_attr_value *value)
{
struct cds_lfht_iter iter;
struct cds_lfht_node *node;
{
struct cds_lfht_iter iter;
struct cds_lfht_node *node;
@@
-171,24
+166,25
@@
static struct process_attr_tracker_value_node *process_attr_tracker_lookup(
rcu_read_lock();
cds_lfht_lookup(tracker->inclusion_set_ht,
process_attr_value_hash(value),
rcu_read_lock();
cds_lfht_lookup(tracker->inclusion_set_ht,
process_attr_value_hash(value),
- match_inclusion_set_value, value, &iter);
+ match_inclusion_set_value,
+ value,
+ &iter);
node = cds_lfht_iter_get_node(&iter);
rcu_read_unlock();
node = cds_lfht_iter_get_node(&iter);
rcu_read_unlock();
- return node ?
container_of(node, struct process_attr_tracker_value_node,
-
inclusion_set_ht_node) :
-
NULL
;
+ return node ?
lttng::utils::container_of(
+
node, &process_attr_tracker_value_node::
inclusion_set_ht_node) :
+
nullptr
;
}
/* Protected by session mutex held by caller. */
}
/* Protected by session mutex held by caller. */
-enum process_attr_tracker_status
process_attr_tracker_inclusion_set_add_value(
-
struct process_attr_tracker *tracker,
- const struct process_attr_value *value)
+enum process_attr_tracker_status
+
process_attr_tracker_inclusion_set_add_value(
struct process_attr_tracker *tracker,
+
const struct process_attr_value *value)
{
{
- enum process_attr_tracker_status status =
- PROCESS_ATTR_TRACKER_STATUS_OK;
- struct process_attr_value *value_copy = NULL;
- struct process_attr_tracker_value_node *value_node = NULL;
+ enum process_attr_tracker_status status = PROCESS_ATTR_TRACKER_STATUS_OK;
+ struct process_attr_value *value_copy = nullptr;
+ struct process_attr_tracker_value_node *value_node = nullptr;
rcu_read_lock();
if (tracker->policy != LTTNG_TRACKING_POLICY_INCLUDE_SET) {
rcu_read_lock();
if (tracker->policy != LTTNG_TRACKING_POLICY_INCLUDE_SET) {
@@
-201,7
+197,7
@@
enum process_attr_tracker_status process_attr_tracker_inclusion_set_add_value(
goto end;
}
goto end;
}
- value_node =
(process_attr_tracker_value_node *) zmalloc(sizeof(*value_node)
);
+ value_node =
zmalloc<process_attr_tracker_value_node>(
);
if (!value_node) {
status = PROCESS_ATTR_TRACKER_STATUS_ERROR;
goto end;
if (!value_node) {
status = PROCESS_ATTR_TRACKER_STATUS_ERROR;
goto end;
@@
-215,10
+211,10
@@
enum process_attr_tracker_status process_attr_tracker_inclusion_set_add_value(
value_node->value = value_copy;
cds_lfht_add(tracker->inclusion_set_ht,
value_node->value = value_copy;
cds_lfht_add(tracker->inclusion_set_ht,
-
process_attr_value_hash(value_copy),
-
&value_node->inclusion_set_ht_node);
- value_copy =
NULL
;
- value_node =
NULL
;
+ process_attr_value_hash(value_copy),
+ &value_node->inclusion_set_ht_node);
+ value_copy =
nullptr
;
+ value_node =
nullptr
;
end:
if (value_copy) {
process_attr_value_destroy(value_copy);
end:
if (value_copy) {
process_attr_value_destroy(value_copy);
@@
-232,13
+228,11
@@
end:
/* Protected by session mutex held by caller. */
enum process_attr_tracker_status
/* Protected by session mutex held by caller. */
enum process_attr_tracker_status
-process_attr_tracker_inclusion_set_remove_value(
- struct process_attr_tracker *tracker,
- const struct process_attr_value *value)
+process_attr_tracker_inclusion_set_remove_value(struct process_attr_tracker *tracker,
+ const struct process_attr_value *value)
{
struct process_attr_tracker_value_node *value_node;
{
struct process_attr_tracker_value_node *value_node;
- enum process_attr_tracker_status status =
- PROCESS_ATTR_TRACKER_STATUS_OK;
+ enum process_attr_tracker_status status = PROCESS_ATTR_TRACKER_STATUS_OK;
rcu_read_lock();
if (tracker->policy != LTTNG_TRACKING_POLICY_INCLUDE_SET) {
rcu_read_lock();
if (tracker->policy != LTTNG_TRACKING_POLICY_INCLUDE_SET) {
@@
-258,16
+252,15
@@
end:
return status;
}
return status;
}
-enum process_attr_tracker_status
process_attr_tracker_get_inclusion_set(
-
const struct process_attr_tracker *tracker,
- struct lttng_process_attr_values **_values)
+enum process_attr_tracker_status
+
process_attr_tracker_get_inclusion_set(
const struct process_attr_tracker *tracker,
+
struct lttng_process_attr_values **_values)
{
struct lttng_ht_iter iter;
struct process_attr_tracker_value_node *value_node;
{
struct lttng_ht_iter iter;
struct process_attr_tracker_value_node *value_node;
- enum process_attr_tracker_status status =
- PROCESS_ATTR_TRACKER_STATUS_OK;
+ enum process_attr_tracker_status status = PROCESS_ATTR_TRACKER_STATUS_OK;
struct lttng_process_attr_values *values;
struct lttng_process_attr_values *values;
- struct process_attr_value *new_value =
NULL
;
+ struct process_attr_value *new_value =
nullptr
;
values = lttng_process_attr_values_create();
if (!values) {
values = lttng_process_attr_values_create();
if (!values) {
@@
-281,8
+274,8
@@
enum process_attr_tracker_status process_attr_tracker_get_inclusion_set(
}
rcu_read_lock();
}
rcu_read_lock();
- cds_lfht_for_each_entry (
tracker->inclusion_set_ht, &iter.iter,
-
value_node, inclusion_set_ht_node) {
+ cds_lfht_for_each_entry (
+
tracker->inclusion_set_ht, &iter.iter,
value_node, inclusion_set_ht_node) {
int ret;
new_value = process_attr_value_copy(value_node->value);
int ret;
new_value = process_attr_value_copy(value_node->value);
@@
-291,14
+284,13
@@
enum process_attr_tracker_status process_attr_tracker_get_inclusion_set(
goto error_unlock;
}
goto error_unlock;
}
- ret = lttng_dynamic_pointer_array_add_pointer(
- &values->array, new_value);
+ ret = lttng_dynamic_pointer_array_add_pointer(&values->array, new_value);
if (ret) {
status = PROCESS_ATTR_TRACKER_STATUS_ERROR;
goto error_unlock;
}
if (ret) {
status = PROCESS_ATTR_TRACKER_STATUS_ERROR;
goto error_unlock;
}
- new_value =
NULL
;
+ new_value =
nullptr
;
}
rcu_read_unlock();
*_values = values;
}
rcu_read_unlock();
*_values = values;
This page took
0.027499 seconds
and
4
git commands to generate.