diff options
author | Mike Gorse <mgorse@suse.com> | 2013-07-10 15:20:53 -0500 |
---|---|---|
committer | Mike Gorse <mgorse@suse.com> | 2013-07-10 15:20:53 -0500 |
commit | 5c7e53d9924dabf8082fa97b247b1529e2e4e8f5 (patch) | |
tree | d05d3a90f10d9ff0dc4673ddc018878ddfa7f0c5 /dbind | |
parent | 5da70658ed42ab4e33e8b47db2e930bb5977d624 (diff) | |
download | at-spi2-core-5c7e53d9924dabf8082fa97b247b1529e2e4e8f5.tar.gz |
Cancel pending calls when giving up on them
When timing out without having received a reply from a pending call,
then
cancel the call so that it will be removed from the DBusConnection's
queue. This will hopefully prevent the call and the
SpiReentrantCallClosure from being leaked.
Note that this code is still behaving oddly (why isn't a notification
being sent by libdbus when the specified amount of time has ellapsed?)
Diffstat (limited to 'dbind')
-rw-r--r-- | dbind/dbind.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/dbind/dbind.c b/dbind/dbind.c index a463308e..b83071a2 100644 --- a/dbind/dbind.c +++ b/dbind/dbind.c @@ -76,10 +76,12 @@ dbind_send_and_allow_reentry (DBusConnection * bus, DBusMessage * message, DBusE closure = g_new0 (SpiReentrantCallClosure, 1); closure->reply = NULL; atspi_dbus_connection_setup_with_g_main(bus, NULL); - if (!dbus_connection_send_with_reply (bus, message, &pending, dbind_timeout)) + if (!dbus_connection_send_with_reply (bus, message, &pending, dbind_timeout) + || !pending) + { + g_free (closure); return NULL; - if (!pending) - return NULL; + } dbus_pending_call_set_notify (pending, set_reply, (void *) closure, g_free); closure->reply = NULL; @@ -89,11 +91,15 @@ dbind_send_and_allow_reentry (DBusConnection * bus, DBusMessage * message, DBusE { if (!dbus_connection_read_write_dispatch (bus, dbind_timeout)) { + //dbus_pending_call_set_notify (pending, NULL, NULL, NULL); + dbus_pending_call_cancel (pending); dbus_pending_call_unref (pending); return NULL; } if (time_elapsed (&tv) > dbind_timeout) { + //dbus_pending_call_set_notify (pending, NULL, NULL, NULL); + dbus_pending_call_cancel (pending); dbus_pending_call_unref (pending); dbus_set_error_const (error, "org.freedesktop.DBus.Error.NoReply", "timeout from dbind"); |