egg-task-cache: handle the cancellation in an idle callback
The caller's GTask was created in an earlier iteration of the GMainLoop. Hence, the g_task_return_error_if_cancelled will complete immediately, and there is a possibility that the GTask might be destroyed before returning to the GMainLoop. If that happens, it will deadlock because it would be disconnecting from the GCancellable from the GCancellable::cancelled handler. It is also not safe to avoid disconnecting from the GCancellable, in case it was cancelled, because, if reset, it can emit the signal a second time and we will be accessing invalid memory. Hence the safest option is to handle the cancellation in an idle callback and immediately returning to the GMainLoop in the "cancelled" handler. https://bugzilla.gnome.org/show_bug.cgi?id=779660
parent
5ad9526c
Please register or sign in to comment