Skip to content

Commit

Permalink
commons: close fds we dup-ed after sending them
Browse files Browse the repository at this point in the history
  • Loading branch information
elinorbgr authored and vberger committed Jan 25, 2019
1 parent 6d7e2c0 commit 5600194
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
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

0 comments on commit 5600194

Please sign in to comment.