From ffdf2e71d9e67980727aa994b77fca36ef5246c6 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 10 Aug 2010 12:18:09 +0100 Subject: When doing SRV lookups, return an array with all RRs instead of just the first one. The first isn't always the best one and this is currently causing GTalk issues when talk2.l.google.com (which is currently dead) is first. --- protocols/jabber/jabber.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'protocols') diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 229e35bf..e3717526 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -95,7 +95,7 @@ static void jabber_login( account_t *acc ) { struct im_connection *ic = imcb_new( acc ); struct jabber_data *jd = g_new0( struct jabber_data, 1 ); - struct ns_srv_reply *srv = NULL; + struct ns_srv_reply **srvl = NULL, *srv; char *connect_to, *s; int i; @@ -195,9 +195,19 @@ static void jabber_login( account_t *acc ) /* Figure out the hostname to connect to. */ if( acc->server && *acc->server ) connect_to = acc->server; - else if( ( srv = srv_lookup( "xmpp-client", "tcp", jd->server ) ) || - ( srv = srv_lookup( "jabber-client", "tcp", jd->server ) ) ) + else if( ( srvl = srv_lookup( "xmpp-client", "tcp", jd->server ) ) || + ( srvl = srv_lookup( "jabber-client", "tcp", jd->server ) ) ) + { + /* Find the lowest-priority one. These usually come + back in random/shuffled order. Not looking at + weights etc for now. */ + srv = *srvl; + for( i = 1; srvl[i]; i ++ ) + if( srvl[i]->prio < srv->prio ) + srv = srvl[i]; + connect_to = srv->name; + } else connect_to = jd->server; @@ -226,7 +236,7 @@ static void jabber_login( account_t *acc ) { jd->fd = proxy_connect( connect_to, srv ? srv->port : set_getint( &acc->set, "port" ), jabber_connected_plain, ic ); } - g_free( srv ); + srv_free( srvl ); if( jd->fd == -1 ) { -- cgit v1.2.3