+}
+
+static inline
+int shm_close_wait_fd(struct lttng_ust_shm_handle *handle,
+ struct shm_ref *ref)
+{
+ struct shm_object_table *table = handle->table;
+ struct shm_object *obj;
+ int wait_fd;
+ size_t index;
+ int ret;
+
+ index = (size_t) ref->index;
+ if (caa_unlikely(index >= table->allocated_len))
+ return -EPERM;
+ obj = &table->objects[index];
+ wait_fd = obj->wait_fd[0];
+ if (wait_fd < 0)
+ return -ENOENT;
+ obj->wait_fd[0] = -1;
+ ret = close(wait_fd);
+ if (ret) {
+ ret = -errno;
+ return ret;
+ }
+ return 0;
+}
+
+static inline
+int shm_close_wakeup_fd(struct lttng_ust_shm_handle *handle,
+ struct shm_ref *ref)
+{
+ struct shm_object_table *table = handle->table;
+ struct shm_object *obj;
+ int wakeup_fd;
+ size_t index;
+ int ret;
+
+ index = (size_t) ref->index;
+ if (caa_unlikely(index >= table->allocated_len))
+ return -EPERM;
+ obj = &table->objects[index];
+ wakeup_fd = obj->wait_fd[1];
+ if (wakeup_fd < 0)
+ return -ENOENT;
+ obj->wait_fd[1] = -1;
+ ret = close(wakeup_fd);
+ if (ret) {
+ ret = -errno;
+ return ret;
+ }
+ return 0;
+}