mirror of
https://github.com/YaLTeR/wl-clipboard-rs.git
synced 2025-10-06 00:32:41 +02:00
Clear O_NONBLOCK
Fixes 7e4f56d11
, apparently io::copy() can't deal with nonblocking fds.
This commit is contained in:
@@ -10,6 +10,7 @@ use std::sync::mpsc::sync_channel;
|
||||
use std::{iter, thread};
|
||||
|
||||
use log::trace;
|
||||
use rustix::fs::{fcntl_setfl, OFlags};
|
||||
use wayland_client::globals::GlobalListContents;
|
||||
use wayland_client::protocol::wl_registry::WlRegistry;
|
||||
use wayland_client::protocol::wl_seat::WlSeat;
|
||||
@@ -350,6 +351,11 @@ impl Dispatch<ZwlrDataControlSourceV1, ()> for State {
|
||||
|
||||
let file = File::open(data_path).map_err(DataSourceError::FileOpen);
|
||||
let result = file.and_then(|mut data_file| {
|
||||
// Clear O_NONBLOCK, otherwise io::copy() will stop halfway.
|
||||
fcntl_setfl(&fd, OFlags::empty())
|
||||
.map_err(io::Error::from)
|
||||
.map_err(DataSourceError::Copy)?;
|
||||
|
||||
let mut target_file = File::from(fd);
|
||||
io::copy(&mut data_file, &mut target_file).map_err(DataSourceError::Copy)
|
||||
});
|
||||
|
@@ -278,7 +278,7 @@ fn copy_multi_no_additional_text_mime_types_test() {
|
||||
fn copy_large() {
|
||||
// Assuming the default pipe capacity is 65536.
|
||||
let mut bytes_to_copy = vec![];
|
||||
for i in 0..70000 {
|
||||
for i in 0..65536 * 10 {
|
||||
bytes_to_copy.push((i % 256) as u8);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user