cpw.malu.xmpp.jingle_ft: 22fa6ad0: Fail on a streamhost if the connect call...

malu at pidgin.im malu at pidgin.im
Tue Apr 14 18:20:34 EDT 2009


-----------------------------------------------------------------
Revision: 22fa6ad0a8bb8bfcdb0dac4b7b5c519d33a7eab6
Ancestor: ebe48bcae99c59d5523e5f5cb318b9eccc3916d0
Author: malu at pidgin.im
Date: 2009-04-14T22:15:56
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/22fa6ad0a8bb8bfcdb0dac4b7b5c519d33a7eab6

Modified files:
        libpurple/protocols/jabber/jingle/s5b.c

ChangeLog: 

Fail on a streamhost if the connect callback gets a socket < 0
This should prevent stalling when DNS lookup on a IP is successful, when in
fact the other client is on another LAN

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/s5b.c	cc7039c795e4598285107ab8217e318eadc1c7ce
+++ libpurple/protocols/jabber/jingle/s5b.c	e2076764f158c9a0bcfcb185a6b44797d136025d
@@ -892,6 +892,32 @@ jingle_s5b_transport_accept_cb(JabberStr
 	g_free(cd);
 }
 
+static void jingle_s5b_attempt_connect_internal(gpointer data);
+
+static gboolean
+jingle_s5b_connect_timeout_cb(gpointer data)
+{
+	JingleS5B *s5b = ((JingleS5BConnectData *) data)->s5b;
+	
+	purple_debug_info("jingle-s5b", "in jingle_s5b_connect_timeout_cb\n");
+	/* cancel timeout */
+	purple_timeout_remove(s5b->priv->connect_timeout);
+	s5b->priv->connect_timeout = 0;
+	
+	/* advance streamhost "counter" */
+	if (s5b->priv->remaining_streamhosts) {
+		s5b->priv->remaining_streamhosts = 
+			s5b->priv->remaining_streamhosts->data;
+		purple_debug_info("jingle-s5b", "trying next streamhost\n");
+		/* if remaining_streamhost is NULL here, this call will result in a
+		 streamhost error (and potentially fallback to IBB) */
+		jingle_s5b_attempt_connect_internal(data);
+	}
+	
+	return FALSE;
+}
+
+
 static void
 jingle_s5b_connect_cb(gpointer data, gint source, const gchar *error_message)
 {
@@ -900,18 +926,26 @@ jingle_s5b_connect_cb(gpointer data, gin
 	JingleSession *session = cd->session;
 	JabberIq *result = NULL;
 	
-	purple_debug_info("jingle-s5b", "Successful in connecting!\n");
-	
-	s5b->priv->connect_data = NULL;
-	s5b->priv->remote_fd = source;
-	s5b->priv->is_connected_to_remote = TRUE;
-	
 	/* cancel timeout if set */
 	if (s5b->priv->connect_timeout) {
 		purple_timeout_remove(s5b->priv->connect_timeout);
 		s5b->priv->connect_timeout = 0;
 	}
 
+	if (source < 0) {
+		/* failed to connect */
+		/* trigger the a "timeout" to get to the next streamhost */
+		jingle_s5b_connect_timeout_cb(data);
+		return;
+	}
+	
+	purple_debug_info("jingle-s5b", "Successful in connecting!\n");
+	
+	s5b->priv->connect_data = NULL;
+	s5b->priv->remote_fd = source;
+	s5b->priv->is_connected_to_remote = TRUE;
+	
+	
 	/* set the currently tried streamhost as the successfull one */
 	s5b->priv->successfull_remote_streamhost =
 		(JabberBytestreamsStreamhost *) s5b->priv->remaining_streamhosts->data;
@@ -925,31 +959,7 @@ jingle_s5b_connect_cb(gpointer data, gin
 	jabber_iq_send(result);
 }
 	
-static void jingle_s5b_attempt_connect_internal(gpointer data);
 
-static gboolean
-jingle_s5b_connect_timeout_cb(gpointer data)
-{
-	JingleS5B *s5b = ((JingleS5BConnectData *) data)->s5b;
-	
-	purple_debug_info("jingle-s5b", "in jingle_s5b_connect_timeout_cb\n");
-	/* cancel timeout */
-	purple_timeout_remove(s5b->priv->connect_timeout);
-	s5b->priv->connect_timeout = 0;
-	
-	/* advance streamhost "counter" */
-	if (s5b->priv->remaining_streamhosts) {
-		s5b->priv->remaining_streamhosts = 
-			s5b->priv->remaining_streamhosts->data;
-		purple_debug_info("jingle-s5b", "trying next streamhost\n");
-		/* if remaining_streamhost is NULL here, this call will result in a
-		 streamhost error (and potentially fallback to IBB) */
-		jingle_s5b_attempt_connect_internal(data);
-	}
-	
-	return FALSE;
-}
-
 static void
 jingle_s5b_attempt_connect_internal(gpointer data)
 {


More information about the Commits mailing list