Mercurial > pidgin
comparison libpurple/dnsquery.c @ 26987:cd78ea46e9bd
merge of '7c614b09b72037ebd86c03fbbeac7794a155547b'
and 'af18689b86389686230fc6ce83cbba52690ce0cb'
| author | Paul Aurich <paul@darkrain42.org> |
|---|---|
| date | Sat, 30 May 2009 00:32:50 +0000 |
| parents | c162a088489f |
| children | 627d23bfdb05 |
comparison
equal
deleted
inserted
replaced
| 26986:42bff519973b | 26987:cd78ea46e9bd |
|---|---|
| 30 #include "dnsquery.h" | 30 #include "dnsquery.h" |
| 31 #include "notify.h" | 31 #include "notify.h" |
| 32 #include "prefs.h" | 32 #include "prefs.h" |
| 33 #include "util.h" | 33 #include "util.h" |
| 34 | 34 |
| 35 #ifndef _WIN32 | |
| 36 #include <resolv.h> | |
| 37 #endif | |
| 38 | |
| 35 #if (defined(__APPLE__) || defined (__unix__)) && !defined(__osf__) | 39 #if (defined(__APPLE__) || defined (__unix__)) && !defined(__osf__) |
| 36 #define PURPLE_DNSQUERY_USE_FORK | 40 #define PURPLE_DNSQUERY_USE_FORK |
| 37 #endif | 41 #endif |
| 38 /************************************************************************** | 42 /************************************************************************** |
| 39 * DNS query API | 43 * DNS query API |
| 254 * passing a number already, we know this | 258 * passing a number already, we know this |
| 255 * value will not be really used by the C | 259 * value will not be really used by the C |
| 256 * library. | 260 * library. |
| 257 */ | 261 */ |
| 258 hints.ai_socktype = SOCK_STREAM; | 262 hints.ai_socktype = SOCK_STREAM; |
| 263 #ifdef AI_ADDRCONFIG | |
| 264 hints.ai_flags |= AI_ADDRCONFIG; | |
| 265 #endif /* AI_ADDRCONFIG */ | |
| 259 rc = getaddrinfo(dns_params.hostname, servname, &hints, &res); | 266 rc = getaddrinfo(dns_params.hostname, servname, &hints, &res); |
| 260 write_to_parent(child_out, &rc, sizeof(rc)); | 267 write_to_parent(child_out, &rc, sizeof(rc)); |
| 261 if (rc != 0) { | 268 if (rc != 0) { |
| 262 close(child_out); | 269 close(child_out); |
| 263 if (show_debug) | 270 if (show_debug) |
| 323 | 330 |
| 324 if(already_done) | 331 if(already_done) |
| 325 return; | 332 return; |
| 326 already_done = TRUE; | 333 already_done = TRUE; |
| 327 ppid = getppid(); | 334 ppid = getppid(); |
| 328 snprintf(s, sizeof(s), "/proc/%d/exe", ppid); | 335 g_snprintf(s, sizeof(s), "/proc/%d/exe", ppid); |
| 329 n = readlink(s, e, sizeof(e)); | 336 n = readlink(s, e, sizeof(e)); |
| 330 if(n < 0) | 337 if(n < 0) |
| 331 return; | 338 return; |
| 332 | 339 |
| 333 e[MIN(n,sizeof(e)-1)] = '\0'; | 340 e[MIN(n,sizeof(e)-1)] = '\0'; |
| 566 query_data->hostname, purple_gai_strerror(err)); | 573 query_data->hostname, purple_gai_strerror(err)); |
| 567 #else | 574 #else |
| 568 g_snprintf(message, sizeof(message), _("Error resolving %s: %d"), | 575 g_snprintf(message, sizeof(message), _("Error resolving %s: %d"), |
| 569 query_data->hostname, err); | 576 query_data->hostname, err); |
| 570 #endif | 577 #endif |
| 578 /* Re-read resolv.conf and friends in case DNS servers have changed */ | |
| 579 res_init(); | |
| 580 | |
| 571 purple_dnsquery_failed(query_data, message); | 581 purple_dnsquery_failed(query_data, message); |
| 572 | |
| 573 } else if (rc > 0) { | 582 } else if (rc > 0) { |
| 574 /* Success! */ | 583 /* Success! */ |
| 575 while (rc > 0) { | 584 while (rc > 0) { |
| 576 rc = read(query_data->resolver->fd_out, &addrlen, sizeof(addrlen)); | 585 rc = read(query_data->resolver->fd_out, &addrlen, sizeof(addrlen)); |
| 577 if (rc > 0 && addrlen > 0) { | 586 if (rc > 0 && addrlen > 0) { |
| 704 * passing a number already, we know this | 713 * passing a number already, we know this |
| 705 * value will not be really used by the C | 714 * value will not be really used by the C |
| 706 * library. | 715 * library. |
| 707 */ | 716 */ |
| 708 hints.ai_socktype = SOCK_STREAM; | 717 hints.ai_socktype = SOCK_STREAM; |
| 718 #ifdef AI_ADDRCONFIG | |
| 719 hints.ai_flags |= AI_ADDRCONFIG; | |
| 720 #endif /* AI_ADDRCONFIG */ | |
| 709 if ((rc = getaddrinfo(query_data->hostname, servname, &hints, &res)) == 0) { | 721 if ((rc = getaddrinfo(query_data->hostname, servname, &hints, &res)) == 0) { |
| 710 tmp = res; | 722 tmp = res; |
| 711 while(res) { | 723 while(res) { |
| 712 query_data->hosts = g_slist_append(query_data->hosts, | 724 query_data->hosts = g_slist_append(query_data->hosts, |
| 713 GSIZE_TO_POINTER(res->ai_addrlen)); | 725 GSIZE_TO_POINTER(res->ai_addrlen)); |
