[Bug 34932] Use WockyMetaPorter
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Wed Mar 23 17:10:08 CET 2011
https://bugs.freedesktop.org/show_bug.cgi?id=34932
--- Comment #3 from Will Thompson <will.thompson at collabora.co.uk> 2011-03-23 09:10:05 PDT ---
+iq_close_reply_cb (GObject *source_object,
+ GAsyncResult *result,
gpointer user_data)
{
+ WockyPorter *porter = WOCKY_PORTER (source_object);
+ GError *error = NULL;
+ WockyStanza *stanza;
+
+ stanza = wocky_porter_send_iq_finish (porter, result, &error);
+
+ if (stanza == NULL)
+ {
+ DEBUG ("Failed to close IQ: %s", error->message);
+ g_clear_error (&error);
+ }
+
+ g_object_unref (stanza);
}
Yeah, unreffing that NULL stanza is gonna end well. :þ
static void
+make_porter_connections (GibberBytestreamIBB *self)
+{
+ GibberBytestreamIBBPrivate *priv = GIBBER_BYTESTREAM_IBB_GET_PRIVATE (self);
+ static gboolean done = FALSE;
+ gchar *jid;
+
+ if (done)
+ return;
+
+ jid = wocky_contact_dup_jid (priv->contact);
+
+ priv->stanza_received_id = wocky_porter_register_handler_from (priv->porter,
+ WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_TYPE_NONE, jid,
+ WOCKY_PORTER_HANDLER_PRIORITY_NORMAL, received_stanza_cb, self, NULL);
+
+ g_free (jid);
+
+ done = TRUE;
+}
This is wrong. 'done' is not specific to 'self', so only the first
GibberBytestreamIBB will ever work.
Also:
+ case PROP_PORTER:
+ priv->porter = g_value_dup_object (value);
+
+ if (priv->porter != NULL && priv->contact != NULL)
+ make_porter_connections (self);
+ break;
+ case PROP_CONTACT:
+ priv->contact = g_value_dup_object (value);
+
+ if (priv->porter != NULL && priv->contact != NULL)
+ make_porter_connections (self);
I'd just add
+ if (priv->porter != NULL && priv->contact != NULL)
+ make_porter_connections (self);
to _constructed(), and then you wouldn't need to track whether it's been done
or not.
Ditto OOB.
+ conn = wocky_meta_porter_borrow_connection (WOCKY_META_PORTER
(priv->porter),
+ priv->contact);
+
+ if (conn != NULL)
+ socket_address = g_socket_connection_get_remote_address (conn, NULL);
+
+ if (conn == NULL || socket_address == NULL)
+ {
+ /* I'm too lazy to create more specific errors for this as it should
+ * never happen while using salut anyway.. */
+ GError e = { GIBBER_XMPP_ERROR, XMPP_ERROR_ITEM_NOT_FOUND,
+ "Unsable get socket address for the control connection" };
+ DEBUG ("Could not get socket address for the control connection" );
+ gibber_bytestream_iface_close (GIBBER_BYTESTREAM_IFACE (self), &e);
+ goto out;
+ }
+
+ if (!g_socket_address_to_native (G_SOCKET_ADDRESS (address),
&(addr.storage),
+ sizeof (addr.storage), &error))
+ {
+ GError e = { GIBBER_XMPP_ERROR, XMPP_ERROR_ITEM_NOT_FOUND,
+ "Failed to turn socket address into bytes" };
+ DEBUG ("Failed to get native socket address: %s", error->message);
+ gibber_bytestream_iface_close (GIBBER_BYTESTREAM_IFACE (self), &e);
+ g_clear_error (&error);
+ goto out;
+ }
+
+ g_object_unref (socket_address);
+
The second error path leaks socket_address. And do you really mean to get a
GSocketAddress, cast some other random thing to a GSocketAddress and call a
method on it, and then unref the GSocketAddress you grabbed, unused?
http://cgit.freedesktop.org/~jonny/telepathy-salut/commit/?h=meta-porter&id=a6bf9ee54e934988f59a3d3296e3cc476b1bb703
What's the effect of this? Does gibber_file_transfer_is_file_offer() check that
from is not NULL?
--
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the telepathy-bugs
mailing list