Skip to content
Commit 83605e2d authored by Ray Strode's avatar Ray Strode Committed by Alexander Larsson
Browse files

gcancellable: allow g_cancellable_disconnect from "cancelled" handler on same thread

g_cancellable_disconnect will wait until any pending "cancelled"
handlers finish.  This is useful because disconnecting a handler can have the
side-effect of freeing data that the cancelled handler may rely on.
Unfortunately, the code used to enforce this synchronization between
"cancelled" handlers and g_cancellable_disconnect will also cause
deadlock if the cancelled handler itself calls g_cancellable_disconect.

Obviously, if g_cancellable_disconnect is explicitly called by a "cancelled"
handler, then the "cancelled" handler is shouldering the responsibility
of not using any data that may be freed by disconnection.

Also, g_cancellable_disconnect can be called in unexpected places by
lower layers in the code (for instance as a result of g_source_destroy).
In practice, this means it's easy for deadlocks to inadvertently crop
up when using "cancelled" handlers.

For these reasons, it would be good to fix the deadlock.

This commit prevents the deadlock by allowing foregoing synchronization,
if a pending "cancelled" handler is in the same thread as the
g_cancellabale_disconnnect call.

https://bugzilla.gnome.org/show_bug.cgi?id=705395
parent 795a3614
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment