size_t mmap_len;
struct lttng_ust_shm_handle *handle;
int nr_streams;
+ int shm_fd_is_copy;
+ int wait_fd_is_copy;
};
/* Forward declaration for UST. */
void *mmap_base;
size_t mmap_len;
enum lttng_event_output output; /* splice or mmap */
+ int shm_fd_is_copy;
+ int wait_fd_is_copy;
/* For UST */
struct lttng_ust_lib_ring_buffer *buf;
int cpu;
if (stream->out_fd >= 0) {
close(stream->out_fd);
}
- if (stream->wait_fd >= 0) {
+ if (stream->wait_fd >= 0 && !stream->wait_fd_is_copy) {
close(stream->wait_fd);
}
- if (stream->shm_fd >= 0 && stream->wait_fd != stream->shm_fd) {
+ if (stream->shm_fd >= 0 && stream->wait_fd != stream->shm_fd
+ && !stream->shm_fd_is_copy) {
close(stream->shm_fd);
}
if (!--stream->chan->refcount)
perror("munmap");
}
}
- if (channel->wait_fd >= 0) {
+ if (channel->wait_fd >= 0 && !channel->wait_fd_is_copy) {
close(channel->wait_fd);
}
- if (channel->shm_fd >= 0 && channel->wait_fd != channel->shm_fd) {
+ if (channel->shm_fd >= 0 && channel->wait_fd != channel->shm_fd
+ && !channel->shm_fd_is_copy) {
close(channel->shm_fd);
}
free(channel);
return -ENOMEM;
}
/*
- * The channel shm and wait fds are passed to ustctl, set them
- * to -1 here.
+ * The channel fds are passed to ustctl, we only keep a copy.
*/
- chan->shm_fd = -1;
- chan->wait_fd = -1;
+ chan->shm_fd_is_copy = 1;
+ chan->wait_fd_is_copy = 1;
+
return 0;
}
return -EINVAL;
}
/*
- * The stream shm and wait fds are passed to ustctl, set them to
- * -1 here.
+ * The stream fds are passed to ustctl, we only keep a copy.
*/
- stream->shm_fd = -1;
- stream->wait_fd = -1;
+ stream->shm_fd_is_copy = 1;
+ stream->wait_fd_is_copy = 1;
return 0;
}