Backport: fd-tracker: remove duplicate clear of O_CREAT flag
[lttng-tools.git] / src / common / fd-tracker / fd-tracker.c
index cdc1691f61da4c124032d0fe56384a7efdfeff7d..36b2e4d2c4c3c9b583c47f86254cd76ecb240ede 100644 (file)
@@ -129,6 +129,7 @@ struct unsuspendable_fd {
        int fd;
        char *name;
        struct cds_lfht_node tracker_node;
+       struct rcu_head rcu_head;
 };
 
 static struct {
@@ -169,14 +170,23 @@ int match_fd(struct cds_lfht_node *node, const void *key)
                        (void *) key);
 }
 
+static
+void delete_unsuspendable_fd(struct rcu_head *head)
+{
+       struct unsuspendable_fd *fd = caa_container_of(head,
+                       struct unsuspendable_fd, rcu_head);
+
+       free(fd->name);
+       free(fd);
+}
+
 static
 void unsuspendable_fd_destroy(struct unsuspendable_fd *entry)
 {
        if (!entry) {
                return;
        }
-       free(entry->name);
-       free(entry);
+       call_rcu(&entry->rcu_head, delete_unsuspendable_fd);
 }
 
 static
@@ -500,11 +510,6 @@ struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
                goto error_destroy;
        }
 
-       /*
-        * Clear the create flag from the open flags as it would make no sense
-        * to use it when restoring a fs handle.
-        */
-       properties.flags &= ~O_CREAT;
        handle->properties = properties;
        properties.path = NULL;
 
@@ -796,6 +801,18 @@ void fs_handle_put_fd(struct fs_handle *handle)
        pthread_mutex_unlock(&handle->lock);
 }
 
+int fs_handle_unlink(struct fs_handle *handle)
+{
+       int ret;
+
+       pthread_mutex_lock(&handle->tracker->lock);
+       pthread_mutex_lock(&handle->lock);
+       ret = lttng_inode_defer_unlink(handle->inode);
+       pthread_mutex_unlock(&handle->lock);
+       pthread_mutex_unlock(&handle->tracker->lock);
+       return ret;
+}
+
 int fs_handle_close(struct fs_handle *handle)
 {
        int ret = 0;
This page took 0.026381 seconds and 5 git commands to generate.