summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2020-09-11 14:38:24 -0700
committerChristian Hergert <chergert@redhat.com>2020-09-11 14:39:14 -0700
commitccf44b694b91d131e32aa84f9f62985e4b1adcc8 (patch)
tree7d6b90e59503e7a5fb877b21ad180e7a37221dfa
parente55bdf87b547aa73792545f4d30644218d8c5f06 (diff)
downloadgtk+-wip/chergert/fix-x11-selection-deadlock.tar.gz
x11: fix deadlock when finalizing output streamwip/chergert/fix-x11-selection-deadlock
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
-rw-r--r--gdk/x11/gdkselectionoutputstream-x11.c6
1 files changed, 5 insertions, 1 deletions
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);