diff options
author | Wilmer van der Gaast <wilmer@google.com> | 2010-08-10 12:18:09 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@google.com> | 2010-08-10 12:18:09 +0100 |
commit | ffdf2e71d9e67980727aa994b77fca36ef5246c6 (patch) | |
tree | 59277a71581915c3203f879b4bf8276fdb001dbf /protocols/jabber/jabber.c | |
parent | f32c14c649e854fbfb7b8e495e2ebc8459ee5b6f (diff) |
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.
Diffstat (limited to 'protocols/jabber/jabber.c')
-rw-r--r-- | protocols/jabber/jabber.c | 18 |
1 files changed, 14 insertions, 4 deletions
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 ) { |