#include <common/common.hpp>
#include <common/hashtable/utils.hpp>
+#include <common/urcu.hpp>
#include <inttypes.h>
/*
* Initialize global buffer per UID registry. Should only be called ONCE!.
*/
-void buffer_reg_init_uid_registry(void)
+void buffer_reg_init_uid_registry()
{
/* Should be called once. */
LTTNG_ASSERT(!buffer_registry_uid);
const char *shm_path)
{
int ret = 0;
- struct buffer_reg_uid *reg = NULL;
+ struct buffer_reg_uid *reg = nullptr;
LTTNG_ASSERT(regp);
DBG3("Buffer registry per UID adding to global registry with id: %" PRIu64,
reg->session_id);
- rcu_read_lock();
+ lttng::urcu::read_lock_guard read_lock;
nodep = cds_lfht_add_unique(
ht->ht, ht->hash_fct(reg, lttng_ht_seed), ht->match_fct, reg, ®->node.node);
LTTNG_ASSERT(nodep == ®->node.node);
- rcu_read_unlock();
}
/*
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
- struct buffer_reg_uid *reg = NULL, key;
+ struct buffer_reg_uid *reg = nullptr, key;
struct lttng_ht *ht = buffer_registry_uid;
ASSERT_RCU_READ_LOCKED();
/*
* Initialize global buffer per PID registry. Should only be called ONCE!.
*/
-void buffer_reg_init_pid_registry(void)
+void buffer_reg_init_pid_registry()
{
/* Should be called once. */
LTTNG_ASSERT(!buffer_registry_pid);
const char *shm_path)
{
int ret = 0;
- struct buffer_reg_pid *reg = NULL;
+ struct buffer_reg_pid *reg = nullptr;
LTTNG_ASSERT(regp);
DBG3("Buffer registry per PID adding to global registry with id: %" PRIu64,
reg->session_id);
- rcu_read_lock();
+ lttng::urcu::read_lock_guard read_lock;
lttng_ht_add_unique_u64(buffer_registry_pid, ®->node);
- rcu_read_unlock();
}
/*
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
- struct buffer_reg_pid *reg = NULL;
+ struct buffer_reg_pid *reg = nullptr;
struct lttng_ht *ht = buffer_registry_pid;
DBG3("Buffer registry per PID find id: %" PRIu64, session_id);
uint64_t *consumer_chan_key)
{
struct lttng_ht_iter iter;
- struct buffer_reg_uid *uid_reg = NULL;
- struct buffer_reg_session *session_reg = NULL;
+ struct buffer_reg_uid *uid_reg = nullptr;
+ struct buffer_reg_session *session_reg = nullptr;
struct buffer_reg_channel *reg_chan;
int ret = -1;
- rcu_read_lock();
- /*
- * For the per-uid registry, we have to iterate since we don't have the
- * uid and bitness key.
- */
- cds_list_for_each_entry (uid_reg, buffer_reg_uid_list, lnode) {
- session_reg = uid_reg->registry;
- cds_lfht_for_each_entry (
- session_reg->channels->ht, &iter.iter, reg_chan, node.node) {
- if (reg_chan->key == chan_key) {
- *consumer_chan_key = reg_chan->consumer_key;
- ret = 0;
- goto end;
+ {
+ lttng::urcu::read_lock_guard read_lock;
+
+ /*
+ * For the per-uid registry, we have to iterate since we don't have the
+ * uid and bitness key.
+ */
+ cds_list_for_each_entry (uid_reg, buffer_reg_uid_list, lnode) {
+ session_reg = uid_reg->registry;
+ cds_lfht_for_each_entry (
+ session_reg->channels->ht, &iter.iter, reg_chan, node.node) {
+ if (reg_chan->key == chan_key) {
+ *consumer_chan_key = reg_chan->consumer_key;
+ ret = 0;
+ goto end;
+ }
}
}
}
-
end:
- rcu_read_unlock();
return ret;
}
reg->key = key;
CDS_INIT_LIST_HEAD(®->streams);
- pthread_mutex_init(®->stream_list_lock, NULL);
+ pthread_mutex_init(®->stream_list_lock, nullptr);
lttng_ht_node_init_u64(®->node, key);
*regp = reg;
LTTNG_ASSERT(session);
LTTNG_ASSERT(channel);
- rcu_read_lock();
+ lttng::urcu::read_lock_guard read_lock;
lttng_ht_add_unique_u64(session->channels, &channel->node);
- rcu_read_unlock();
}
/*
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
- struct buffer_reg_channel *chan = NULL;
+ struct buffer_reg_channel *chan = nullptr;
struct lttng_ht *ht;
LTTNG_ASSERT(reg);
{
int ret;
- ret = ust_app_release_object(NULL, regp->obj.ust);
+ ret = ust_app_release_object(nullptr, regp->obj.ust);
if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
ERR("Buffer reg stream release obj handle %d failed with ret %d",
regp->obj.ust->handle,
}
if (regp->obj.ust) {
- ret = ust_app_release_object(NULL, regp->obj.ust);
+ ret = ust_app_release_object(nullptr, regp->obj.ust);
if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
ERR("Buffer reg channel release obj handle %d failed with ret %d",
regp->obj.ust->handle,
DBG3("Buffer registry session destroy");
/* Destroy all channels. */
- rcu_read_lock();
- cds_lfht_for_each_entry (regp->channels->ht, &iter.iter, reg_chan, node.node) {
- ret = lttng_ht_del(regp->channels, &iter);
- LTTNG_ASSERT(!ret);
- buffer_reg_channel_destroy(reg_chan, domain);
+ {
+ lttng::urcu::read_lock_guard read_lock;
+
+ cds_lfht_for_each_entry (regp->channels->ht, &iter.iter, reg_chan, node.node) {
+ ret = lttng_ht_del(regp->channels, &iter);
+ LTTNG_ASSERT(!ret);
+ buffer_reg_channel_destroy(reg_chan, domain);
+ }
}
- rcu_read_unlock();
lttng_ht_destroy(regp->channels);
LTTNG_ASSERT(regp);
- rcu_read_lock();
+ lttng::urcu::read_lock_guard read_lock;
iter.iter.node = ®p->node.node;
ret = lttng_ht_del(buffer_registry_uid, &iter);
LTTNG_ASSERT(!ret);
- rcu_read_unlock();
}
static void rcu_free_buffer_reg_uid(struct rcu_head *head)
goto destroy;
}
- rcu_read_lock();
- /* Get the right socket from the consumer object. */
- socket = consumer_find_socket_by_bitness(regp->bits_per_long, consumer);
- if (!socket) {
- goto unlock;
- }
+ {
+ lttng::urcu::read_lock_guard read_lock;
+ /* Get the right socket from the consumer object. */
+ socket = consumer_find_socket_by_bitness(regp->bits_per_long, consumer);
+ if (!socket) {
+ goto destroy;
+ }
- switch (regp->domain) {
- case LTTNG_DOMAIN_UST:
- if (regp->registry->reg.ust->_metadata_key) {
- /* Return value does not matter. This call will print errors. */
- (void) consumer_close_metadata(socket,
- regp->registry->reg.ust->_metadata_key);
+ switch (regp->domain) {
+ case LTTNG_DOMAIN_UST:
+ if (regp->registry->reg.ust->_metadata_key) {
+ /* Return value does not matter. This call will print errors. */
+ (void) consumer_close_metadata(
+ socket, regp->registry->reg.ust->_metadata_key);
+ }
+ break;
+ default:
+ abort();
+ return;
}
- break;
- default:
- abort();
- rcu_read_unlock();
- return;
}
-unlock:
- rcu_read_unlock();
destroy:
call_rcu(®p->node.head, rcu_free_buffer_reg_uid);
}
/*
* Destroy per PID and UID registry hash table.
*/
-void buffer_reg_destroy_registries(void)
+void buffer_reg_destroy_registries()
{
DBG3("Buffer registry destroy all registry");
lttng_ht_destroy(buffer_registry_uid);