Tue, 01 Feb 2005 05:02:40 +0000
[gaim-migrate @ 11942]
This will prevent the connection process from hanging when the DNS lookup fails. We need to call the callback function regardless of whether the lookup succeeded. (This is in the DNS lookup functionality that is currently #ifdef _WIN32, but is actually portable),
| src/proxy.c | file | annotate | diff | comparison | revisions |
--- a/src/proxy.c Tue Feb 01 04:29:44 2005 +0000 +++ b/src/proxy.c Tue Feb 01 05:02:40 2005 +0000 @@ -651,8 +651,12 @@ static gboolean dns_main_thread_cb(gpointer data) { dns_tdata *td = (dns_tdata*)data; + if (td->errmsg != NULL) { + gaim_debug_info("dns", "%s\n", td->errmsg); + } td->callback(td->hosts, td->data, td->errmsg); g_free(td->hostname); + g_free(td->errmsg); g_free(td); return FALSE; } @@ -662,19 +666,19 @@ dns_tdata *td = (dns_tdata*)data; struct hostent *hp; - if(!(hp = gethostbyname(td->hostname))) { - g_free(td->hostname); - g_free(td); - return 0; - } + if ((hp = gethostbyname(td->hostname))) { + memset(&sin, 0, sizeof(struct sockaddr_in)); + memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length); + sin.sin_family = hp->h_addrtype; + sin.sin_port = htons(td->port); - memset(&sin, 0, sizeof(struct sockaddr_in)); - memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length); - sin.sin_family = hp->h_addrtype; - sin.sin_port = htons(td->port); - - td->hosts = g_slist_append(td->hosts, GINT_TO_POINTER(sizeof(sin))); - td->hosts = g_slist_append(td->hosts, g_memdup(&sin, sizeof(sin))); + td->hosts = g_slist_append(td->hosts, + GINT_TO_POINTER(sizeof(sin))); + td->hosts = g_slist_append(td->hosts, + g_memdup(&sin, sizeof(sin))); + } else { + td->errmsg = g_strdup_printf("DNS error: %d", errno); + } /* back to main thread */ g_idle_add(dns_main_thread_cb, td); return 0;