Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commons: close fds we dup-ed after sending them #236

Merged
merged 1 commit into from
Jan 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
design change above.
- [scanner] Fixed a number of cases where invalid Rust code would be generated if variable
or method names in the protocol were Rust keywords.
- [commons] Properly close FDs we dup-ed after sending them to the server, to avoid leaking
open FDs.

## 0.21.11 -- 2019-01-19

Expand Down
4 changes: 4 additions & 0 deletions wayland-commons/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ impl BufferedSocket {
let bytes = unsafe { ::std::slice::from_raw_parts(words.as_ptr() as *const u8, words.len() * 4) };
let fds = self.out_fds.get_contents();
self.socket.send_msg(bytes, fds)?;
for &fd in fds {
// once the fds are sent, we can close them
let _ = ::nix::unistd::close(fd);
}
}
self.out_data.clear();
self.out_fds.clear();
Expand Down