[telepathy-gabble/telepathy-gabble-0.8] vcard-manager.c: don't crash when a set fails and there are edits pending
Dafydd Harries
dafydd.harries at collabora.co.uk
Fri Aug 28 10:10:54 PDT 2009
---
src/vcard-manager.c | 17 ++++++++++++-
tests/twisted/Makefile.am | 1 +
tests/twisted/vcard/set-set-disconnect.py | 34 +++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 2 deletions(-)
create mode 100644 tests/twisted/vcard/set-set-disconnect.py
diff --git a/src/vcard-manager.c b/src/vcard-manager.c
index f7d2c2b..9b3b96d 100644
--- a/src/vcard-manager.c
+++ b/src/vcard-manager.c
@@ -890,8 +890,21 @@ replace_reply_cb (GabbleConnection *conn,
}
}
- /* If we've received more edit requests in the meantime, send them off. */
- manager_patch_vcard (self, node);
+ if (error != NULL)
+ {
+ if (priv->edits != NULL)
+ {
+ /* All the requests for these edits have just been cancelled. */
+ g_hash_table_destroy (priv->edits);
+ priv->edits = NULL;
+ }
+ }
+ else
+ {
+ /* If we've received more edit requests in the meantime, send them off.
+ */
+ manager_patch_vcard (self, node);
+ }
}
static void
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index f185c28..c8ef519 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -72,6 +72,7 @@ TWISTED_TESTS = \
tubes/test-get-available-tubes.py \
tubes/test-socks5-muc.py \
vcard/overlapping-sets.py \
+ vcard/set-set-disconnect.py \
vcard/test-alias-empty-vcard.py \
vcard/test-alias-pep.py \
vcard/test-alias.py \
diff --git a/tests/twisted/vcard/set-set-disconnect.py b/tests/twisted/vcard/set-set-disconnect.py
new file mode 100644
index 0000000..cd2d295
--- /dev/null
+++ b/tests/twisted/vcard/set-set-disconnect.py
@@ -0,0 +1,34 @@
+
+"""
+Regression test for crash when disconnecting in the middle of a set.
+"""
+
+from servicetest import EventPattern, call_async, sync_dbus
+from gabbletest import exec_test, acknowledge_iq
+import constants as cs
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+ _, iq_event = q.expect_many(
+ EventPattern('dbus-signal', signal='StatusChanged',
+ args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]),
+ EventPattern('stream-iq', to=None, query_ns='vcard-temp',
+ query_name='vCard'))
+
+ acknowledge_iq(stream, iq_event.stanza)
+
+ call_async(
+ q, conn.Avatars, 'SetAvatar', 'Guy.brush', 'image/x-mighty-pirate')
+ iq_event = q.expect(
+ 'stream-iq', iq_type='set', query_ns='vcard-temp', query_name='vCard')
+ call_async(
+ q, conn.Avatars, 'SetAvatar', 'LeChuck.brush', 'image/x-ghost-pirate')
+ conn.Disconnect()
+ q.expect('dbus-signal', signal='StatusChanged',
+ args=[cs.CONN_STATUS_DISCONNECTED, cs.CSR_REQUESTED]),
+ q.expect('dbus-error', method='SetAvatar', name=cs.NOT_AVAILABLE)
+ q.expect('dbus-error', method='SetAvatar', name=cs.NOT_AVAILABLE)
+ sync_dbus(bus, q, conn)
+
+if __name__ == '__main__':
+ exec_test(test)
--
1.5.6.5
More information about the telepathy-commits
mailing list