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
- && !stream->shm_fd_is_copy) {
+ if (stream->shm_fd >= 0 && stream->wait_fd != stream->shm_fd) {
close(stream->shm_fd);
}
if (!--stream->chan->refcount)
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
- && !channel->shm_fd_is_copy) {
+ if (channel->shm_fd >= 0 && channel->wait_fd != channel->shm_fd) {
close(channel->shm_fd);
}
free(channel);
if (!chan->handle) {
return -ENOMEM;
}
- /*
- * The channel fds are passed to ustctl, we only keep a copy.
- */
- chan->shm_fd_is_copy = 1;
chan->wait_fd_is_copy = 1;
+ chan->shm_fd = -1;
return 0;
}
stream->buf = ustctl_open_stream_read(stream->chan->handle, stream->cpu);
if (!stream->buf)
return -EBUSY;
+ /* ustctl_open_stream_read has closed the shm fd. */
+ stream->wait_fd_is_copy = 1;
+ stream->shm_fd = -1;
+
stream->mmap_base = ustctl_get_mmap_base(stream->chan->handle, stream->buf);
if (!stream->mmap_base) {
return -EINVAL;
}
- /*
- * The stream fds are passed to ustctl, we only keep a copy.
- */
- stream->shm_fd_is_copy = 1;
- stream->wait_fd_is_copy = 1;
return 0;
}