[gtk/wip/chergert/fix-x11-selection-deadlock] x11: fix deadlock when finalizing output stream
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/fix-x11-selection-deadlock] x11: fix deadlock when finalizing output stream
- Date: Fri, 11 Sep 2020 21:41:33 +0000 (UTC)
commit ccf44b694b91d131e32aa84f9f62985e4b1adcc8
Author: Christian Hergert <chergert redhat com>
Date: Fri Sep 11 14:38:24 2020 -0700
x11: fix deadlock when finalizing output stream
If we have a very large selection (many MB of textbuffer text) we can
possibly deadlock here trying to flush as the serializer is disposed
and finalized on the main thread.
This avoids it similarly to other places by checking that we are allowed
to flush at this point.
Fixes: #3153
gdk/x11/gdkselectionoutputstream-x11.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gdk/x11/gdkselectionoutputstream-x11.c b/gdk/x11/gdkselectionoutputstream-x11.c
index b9aad4c3f3..6c10a15f2c 100644
--- a/gdk/x11/gdkselectionoutputstream-x11.c
+++ b/gdk/x11/gdkselectionoutputstream-x11.c
@@ -439,7 +439,11 @@ gdk_x11_selection_output_stream_flush (GOutputStream *output_stream,
g_main_context_invoke (NULL, gdk_x11_selection_output_stream_invoke_flush, stream);
g_mutex_lock (&priv->mutex);
- if (gdk_x11_selection_output_stream_needs_flush_unlocked (stream))
+ /* We have to check gdk_x11_selection_output_stream_can_flush() because if
+ * we cannot, nothing will necessarily complete our g_cond_wait().
+ */
+ if (!priv->delete_pending &&
+ gdk_x11_selection_output_stream_needs_flush_unlocked (stream))
g_cond_wait (&priv->cond, &priv->mutex);
g_mutex_unlock (&priv->mutex);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]