Possible deadlock when canceling
Submitted by David Zeuthen
Link to original bug (#650252)
Description
Consier his ::cancelled signal handler
static void on_cancelled (GCancellable *cancellable, gpointer user_data) { MyData *data = user_data; g_cancellable_cancel (data->other_cancellable); }
where data->other_cancellable != cancellable. It will deadlock if being called from g_cancellable_connect(). Should either do the callback without holding the lock or should use a lock per cancellable.
(While on this topic, it would be nice to have some more convenience helpers on GCancellable - for example some way to add timeouts (what I tried to do here) and maybe also a way to chain cancelables together. I find, writing applications and libraries, that it's a little lacking as is.)