Mercurial > pidgin.yaz
changeset 10562:e06da39b467c
[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),
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 01 Feb 2005 05:02:40 +0000 |
parents | 1db4f49de0c6 |
children | 3e2cd3fe8897 |
files | src/proxy.c |
diffstat | 1 files changed, 16 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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;