Mercurial > pidgin
comparison src/proxy.c @ 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 | 351449bb5a74 |
comparison
equal
deleted
inserted
replaced
10561:1db4f49de0c6 | 10562:e06da39b467c |
---|---|
649 char *errmsg; | 649 char *errmsg; |
650 } dns_tdata; | 650 } dns_tdata; |
651 | 651 |
652 static gboolean dns_main_thread_cb(gpointer data) { | 652 static gboolean dns_main_thread_cb(gpointer data) { |
653 dns_tdata *td = (dns_tdata*)data; | 653 dns_tdata *td = (dns_tdata*)data; |
654 if (td->errmsg != NULL) { | |
655 gaim_debug_info("dns", "%s\n", td->errmsg); | |
656 } | |
654 td->callback(td->hosts, td->data, td->errmsg); | 657 td->callback(td->hosts, td->data, td->errmsg); |
655 g_free(td->hostname); | 658 g_free(td->hostname); |
659 g_free(td->errmsg); | |
656 g_free(td); | 660 g_free(td); |
657 return FALSE; | 661 return FALSE; |
658 } | 662 } |
659 | 663 |
660 static gpointer dns_thread(gpointer data) { | 664 static gpointer dns_thread(gpointer data) { |
661 struct sockaddr_in sin; | 665 struct sockaddr_in sin; |
662 dns_tdata *td = (dns_tdata*)data; | 666 dns_tdata *td = (dns_tdata*)data; |
663 struct hostent *hp; | 667 struct hostent *hp; |
664 | 668 |
665 if(!(hp = gethostbyname(td->hostname))) { | 669 if ((hp = gethostbyname(td->hostname))) { |
666 g_free(td->hostname); | 670 memset(&sin, 0, sizeof(struct sockaddr_in)); |
667 g_free(td); | 671 memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length); |
668 return 0; | 672 sin.sin_family = hp->h_addrtype; |
669 } | 673 sin.sin_port = htons(td->port); |
670 | 674 |
671 memset(&sin, 0, sizeof(struct sockaddr_in)); | 675 td->hosts = g_slist_append(td->hosts, |
672 memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length); | 676 GINT_TO_POINTER(sizeof(sin))); |
673 sin.sin_family = hp->h_addrtype; | 677 td->hosts = g_slist_append(td->hosts, |
674 sin.sin_port = htons(td->port); | 678 g_memdup(&sin, sizeof(sin))); |
675 | 679 } else { |
676 td->hosts = g_slist_append(td->hosts, GINT_TO_POINTER(sizeof(sin))); | 680 td->errmsg = g_strdup_printf("DNS error: %d", errno); |
677 td->hosts = g_slist_append(td->hosts, g_memdup(&sin, sizeof(sin))); | 681 } |
678 /* back to main thread */ | 682 /* back to main thread */ |
679 g_idle_add(dns_main_thread_cb, td); | 683 g_idle_add(dns_main_thread_cb, td); |
680 return 0; | 684 return 0; |
681 } | 685 } |
682 | 686 |