diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-10-19 10:49:56 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-10-19 10:49:56 +0100 |
commit | 5e0492da509aad12b93b732c449dae1a016367c1 (patch) | |
tree | bcbb8b67216872b306aad46df6bd557797ba0f53 | |
parent | 6c33e1cd9d9e247b8b2aa95e9617904a317b78c6 (diff) |
GDBusWorker: if a read was cancelled it means we closed the connection
This was a regression caused by my previous work on GDBusWorker thread-safety
(Bug #651268). The symptom is that if you disconnect a GDBusConnection
locally, the default implementation of GDBusConnection::closed
terminates your process, even though it shouldn't do that for
locally-closed connections; this is because GDBusWorker didn't think a
cancelled read was a local close.
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=662100
Bug-NB: NB#287088
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: David Zeuthen <davidz@redhat.com>
-rw-r--r-- | gio/gdbusprivate.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c index c30a4ec4b..38b17f352 100644 --- a/gio/gdbusprivate.c +++ b/gio/gdbusprivate.c @@ -647,7 +647,17 @@ _g_dbus_worker_do_read_cb (GInputStream *input_stream, if (bytes_read == -1) { - _g_dbus_worker_emit_disconnected (worker, TRUE, error); + /* Every async read that uses this callback uses worker->cancellable + * as its GCancellable. worker->cancellable gets cancelled if and only + * if the GDBusConnection tells us to close (either via + * _g_dbus_worker_stop, which is called on last-unref, or directly), + * so a cancelled read must mean our connection was closed locally. + */ + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + _g_dbus_worker_emit_disconnected (worker, FALSE, NULL); + else + _g_dbus_worker_emit_disconnected (worker, TRUE, error); + g_error_free (error); goto out; } |