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

X11: Add timeout for getting clipboard contents #1866

Merged
merged 2 commits into from
Jul 10, 2021

Conversation

psychon
Copy link
Contributor

@psychon psychon commented Jul 9, 2021

When the selection does not answer, the code would just hang while
waiting for a reply. This could e.g. happen when the "other end"
crashes.

Handle this situation by applying a timeout of five seconds for getting
the clipboard contents. After this timeout, the transfer is aborted with
an error.

This was tested by batching handle_request() in druid-shell's clipboard
code to just return Ok(()). Then, I started the following program:

fn main() { druid_shell::Application::new().unwrap().clipboard().put_string("whatever"); }

Afterwards, trying to get the clipboard contents with druid_shell would
just hang.

With this commit, the following happens instead:

 WARN druid_shell::backend::x11::clipboard: Error in Clipboard::do_transfer: ConnectionError(IOError(Custom { kind: TimedOut, error: "Timeout while waiting for selection owner to reply" }))

Signed-off-by: Uli Schlachter psychon@znc.in

When the selection does not answer, the code would just hang while
waiting for a reply. This could e.g. happen when the "other end"
crashes.

Handle this situation by applying a timeout of five seconds for getting
the clipboard contents. After this timeout, the transfer is aborted with
an error.

This was tested by batching handle_request() in druid-shell's clipboard
code to just return Ok(()). Then, I started the following program:

    fn main() { druid_shell::Application::new().unwrap().clipboard().put_string("whatever"); }

Afterwards, trying to get the clipboard contents with druid_shell would
just hang.

With this commit, the following happens instead:

     WARN druid_shell::backend::x11::clipboard: Error in Clipboard::do_transfer: ConnectionError(IOError(Custom { kind: TimedOut, error: "Timeout while waiting for selection owner to reply" }))

Signed-off-by: Uli Schlachter <psychon@znc.in>
Copy link
Collaborator

@maan2003 maan2003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@maan2003 maan2003 merged commit b1bbbbb into linebender:master Jul 10, 2021
@psychon psychon deleted the clipboard-timeout branch July 10, 2021 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants