#include <common/macros.hpp>
#include <common/optional.hpp>
#include <common/string-utils/format.hpp>
+#include <common/urcu.hpp>
#include <common/utils.hpp>
#include <lttng/constant.h>
}
lttng_directory_handle_put(inode->location.directory_handle);
- inode->location.directory_handle = NULL;
+ inode->location.directory_handle = nullptr;
reference_acquired = lttng_directory_handle_get(pool->unlink_directory_handle);
LTTNG_ASSERT(reference_acquired);
inode->location.directory_handle = pool->unlink_directory_handle;
free(inode->location.path);
inode->location.path = inode_unlinked_name;
- inode_unlinked_name = NULL;
+ inode_unlinked_name = nullptr;
LTTNG_OPTIONAL_SET(&inode->unlinked_id, unlinked_id);
pool->file_count++;
end:
goto end;
}
free(inode->location.path);
- inode->location.path = NULL;
+ inode->location.path = nullptr;
lttng_directory_handle_put(inode->location.directory_handle);
- inode->location.directory_handle = NULL;
+ inode->location.directory_handle = nullptr;
pool->file_count--;
if (pool->file_count == 0) {
pool->unlink_directory_path);
}
lttng_directory_handle_put(pool->unlink_directory_handle);
- pool->unlink_directory_handle = NULL;
+ pool->unlink_directory_handle = nullptr;
}
end:
return ret;
return;
}
- rcu_read_lock();
+ lttng::urcu::read_lock_guard read_lock;
cds_lfht_del(inode->registry_ht, &inode->registry_node);
- rcu_read_unlock();
if (inode->unlink_pending) {
int ret;
}
lttng_directory_handle_put(inode->location.directory_handle);
- inode->location.directory_handle = NULL;
+ inode->location.directory_handle = nullptr;
free(inode->location.path);
- inode->location.path = NULL;
+ inode->location.path = nullptr;
call_rcu(&inode->rcu_head, lttng_inode_free);
}
return pool;
error:
lttng_unlinked_file_pool_destroy(pool);
- return NULL;
+ return nullptr;
}
void lttng_unlinked_file_pool_destroy(struct lttng_unlinked_file_pool *pool)
inode->location.directory_handle = new_directory_handle;
/* Ownership transferred. */
inode->location.path = new_path_copy;
- new_path_copy = NULL;
+ new_path_copy = nullptr;
end:
free(new_path_copy);
return ret;
struct lttng_directory_handle *directory_handle,
const char *path)
{
- struct lttng_inode *inode = NULL;
+ struct lttng_inode *inode = nullptr;
char *path_copy;
bool reference_acquired;
inode->unlinked_file_pool = unlinked_file_pool;
/* Ownership of path copy is transferred to inode. */
inode->location.path = path_copy;
- path_copy = NULL;
+ path_copy = nullptr;
inode->location.directory_handle = directory_handle;
end:
free(path_copy);
return inode;
}
-struct lttng_inode_registry *lttng_inode_registry_create(void)
+struct lttng_inode_registry *lttng_inode_registry_create()
{
struct lttng_inode_registry *registry = zmalloc<lttng_inode_registry>();
pthread_mutex_lock(&seed.lock);
if (!seed.initialized) {
- seed.value = (unsigned long) time(NULL);
+ seed.value = (unsigned long) time(nullptr);
seed.initialized = true;
}
pthread_mutex_unlock(&seed.lock);
registry->inodes = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!registry->inodes) {
goto error;
}
return registry;
error:
lttng_inode_registry_destroy(registry);
- return NULL;
+ return nullptr;
}
void lttng_inode_registry_destroy(struct lttng_inode_registry *registry)
return;
}
if (registry->inodes) {
- int ret = cds_lfht_destroy(registry->inodes, NULL);
+ int ret = cds_lfht_destroy(registry->inodes, nullptr);
LTTNG_ASSERT(!ret);
}
struct inode_id id;
struct cds_lfht_iter iter;
struct cds_lfht_node *node;
- struct lttng_inode *inode = NULL;
+ struct lttng_inode *inode = nullptr;
+ lttng::urcu::read_lock_guard read_lock;
ret = fstat(fd, &statbuf);
if (ret < 0) {
id.device = statbuf.st_dev;
id.inode = statbuf.st_ino;
- rcu_read_lock();
cds_lfht_lookup(registry->inodes, lttng_inode_id_hash(&id), lttng_inode_match, &id, &iter);
node = cds_lfht_iter_get_node(&iter);
if (node) {
inode = lttng::utils::container_of(node, <tng_inode::registry_node);
lttng_inode_get(inode);
- goto end_unlock;
+ goto end;
}
inode = lttng_inode_create(&id, registry->inodes, unlinked_file_pool, handle, path);
if (!inode) {
- goto end_unlock;
+ goto end;
}
node = cds_lfht_add_unique(registry->inodes,
&inode->id,
&inode->registry_node);
LTTNG_ASSERT(node == &inode->registry_node);
-end_unlock:
- rcu_read_unlock();
end:
return inode;
}