Fix: futex wait: handle spurious futex wakeups
[lttng-tools.git] / src / common / fd-tracker / fd-tracker.cpp
index 398ec971ddd5fdf5c8e0ff61e987efbad3ac1432..0c24eab5ea016e74b51e818af1bbcbb02c5b24ff 100644 (file)
@@ -80,6 +80,7 @@ struct fd_tracker {
        struct lttng_unlinked_file_pool *unlinked_file_pool;
 };
 
+namespace {
 struct open_properties {
        int flags;
        LTTNG_OPTIONAL(mode_t) mode;
@@ -124,7 +125,7 @@ struct unsuspendable_fd {
        struct rcu_head rcu_head;
 };
 
-static struct {
+struct {
        pthread_mutex_t lock;
        bool initialized;
        unsigned long value;
@@ -133,6 +134,7 @@ static struct {
        .initialized = false,
        .value = 0,
 };
+} /* namespace */
 
 static int match_fd(struct cds_lfht_node *node, const void *key);
 static void unsuspendable_fd_destroy(struct unsuspendable_fd *entry);
@@ -161,8 +163,8 @@ static int fd_tracker_restore_handle(
 /* Match function of the tracker's unsuspendable_fds hash table. */
 static int match_fd(struct cds_lfht_node *node, const void *key)
 {
-       struct unsuspendable_fd *entry = caa_container_of(
-                       node, struct unsuspendable_fd, tracker_node);
+       struct unsuspendable_fd *entry = lttng::utils::container_of(
+                       node, &unsuspendable_fd::tracker_node);
 
        return hash_match_key_ulong(
                        (void *) (unsigned long) entry->fd, (void *) key);
@@ -755,8 +757,8 @@ int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker,
                        ret = -EINVAL;
                        goto end_unlock;
                }
-               entry = caa_container_of(
-                               node, struct unsuspendable_fd, tracker_node);
+               entry = lttng::utils::container_of(
+                               node, &unsuspendable_fd::tracker_node);
 
                cds_lfht_del(tracker->unsuspendable_fds, node);
                unsuspendable_fd_destroy(entry);
@@ -823,7 +825,7 @@ static int fs_handle_tracked_get_fd(struct fs_handle *_handle)
 {
        int ret;
        struct fs_handle_tracked *handle =
-                       container_of(_handle, struct fs_handle_tracked, parent);
+                       lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
 
        /*
         * TODO This should be optimized as it is a fairly hot path.
@@ -864,7 +866,7 @@ end:
 static void fs_handle_tracked_put_fd(struct fs_handle *_handle)
 {
        struct fs_handle_tracked *handle =
-                       container_of(_handle, struct fs_handle_tracked, parent);
+                       lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
 
        pthread_mutex_lock(&handle->lock);
        handle->in_use = false;
@@ -875,7 +877,7 @@ static int fs_handle_tracked_unlink(struct fs_handle *_handle)
 {
        int ret;
        struct fs_handle_tracked *handle =
-                       container_of(_handle, struct fs_handle_tracked, parent);
+                       lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
 
        pthread_mutex_lock(&handle->tracker->lock);
        pthread_mutex_lock(&handle->lock);
@@ -890,7 +892,7 @@ static int fs_handle_tracked_close(struct fs_handle *_handle)
        int ret = 0;
        const char *path = NULL;
        struct fs_handle_tracked *handle =
-                       container_of(_handle, struct fs_handle_tracked, parent);
+                       lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
        struct lttng_directory_handle *inode_directory_handle = NULL;
 
        if (!handle) {
This page took 0.026854 seconds and 4 git commands to generate.