diff options
author | Andrea Azzarone <andrea.azzarone@canonical.com> | 2019-03-04 19:37:09 +0000 |
---|---|---|
committer | Andrea Azzarone <azzaronea@gmail.com> | 2019-03-05 12:07:41 +0000 |
commit | 8856a396fdf4f82d74f65d4037c1946d0d2eb5e1 (patch) | |
tree | d3814bf8abdb88bc1dd6bfa057caa78ff6dd28b7 | |
parent | b0fb39bb547bcf7f48a78659fa626f628fce6031 (diff) | |
download | mutter-8856a396fdf4f82d74f65d4037c1946d0d2eb5e1.tar.gz |
sound-player: Don't deadlock in finish_cb
The function finish_cb can be called as a result of a call to ca_context_cancel
in cancelled_cb. This will result in a deadlock because, as per documentation,
g_cancellable_disconnect cannot be called inside the cancellable handler.
It is possible to detect if the call to finish_cb is caused by ca_context_cancel
checking if error_code == CA_ERROR_CANCELED. To avoid the deadlock we should
call g_signal_handler_disconnect instead g_cancellable_disconnect if this is the
case.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/474
-rw-r--r-- | src/core/meta-sound-player.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/meta-sound-player.c b/src/core/meta-sound-player.c index ab934781a..8ef403936 100644 --- a/src/core/meta-sound-player.c +++ b/src/core/meta-sound-player.c @@ -117,7 +117,11 @@ finish_cb (ca_context *context, { MetaPlayRequest *req = user_data; - g_cancellable_disconnect (req->cancellable, req->cancel_id); + if (error_code != CA_ERROR_CANCELED) + g_cancellable_disconnect (req->cancellable, req->cancel_id); + else if (req->cancellable != NULL && req->cancel_id != 0) + g_signal_handler_disconnect (req->cancellable, req->cancel_id); + meta_play_request_free (req); } |