[Spice-devel] [PATCH spice 2/5] spicec-x11: Remove a race window in selection ownership release code
Arnon Gilboa
agilboa at redhat.com
Thu Oct 7 04:53:42 PDT 2010
ack. and i always believed x11 is perfect.
Hans de Goede wrote:
> Well almost remove it, it was possible that another x11 app would acquire
> selection ownership, and we would receive a release message from the
> agent before having processed the xselection ownership change event.
>
> Then we would set the selection owner to none, overriding the new owner.
> As the comment in the patch indicates there still is a minute window left
> where something similar can happen after this patch. Nothing we can do
> about that (I blame the libX11 selection API).
> ---
> client/x11/platform.cpp | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
> index 8f0665c..cb2431f 100644
> --- a/client/x11/platform.cpp
> +++ b/client/x11/platform.cpp
> @@ -3466,7 +3466,15 @@ void Platform::on_clipboard_release()
> {
> XEvent event;
>
> + if (XGetSelectionOwner(x_display, clipboard_prop) != platform_win) {
> + LOG_INFO("Platform::on_clipboard_release() called while not selection owner");
> + return;
> + }
> + /* Note there is a small race window here where another x11 app could
> + acquire selection ownership and we kick it off again, nothing we
> + can do about that :( */
> XSetSelectionOwner(x_display, clipboard_prop, None, CurrentTime);
> +
> /* Make sure we process the XFixesSetSelectionOwnerNotify event caused
> by this, so we don't end up changing the clipboard owner to none, after
> it has already been re-owned because this event is still pending. */
>
More information about the Spice-devel
mailing list