comparison src/proxy.c @ 10709:cc9922ce3a52

[gaim-migrate @ 12299] That same DNS fix (for real)^2 from oldstatus. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 21 Mar 2005 00:43:26 +0000
parents 7672a83c04da
children 00483ba950bf
comparison
equal deleted inserted replaced
10708:d0d1d631ed49 10709:cc9922ce3a52
423 } 423 }
424 424
425 static void 425 static void
426 gaim_dns_childthread(int child_out, int child_in, dns_params_t *dns_params, gboolean show_debug) 426 gaim_dns_childthread(int child_out, int child_in, dns_params_t *dns_params, gboolean show_debug)
427 { 427 {
428 const int zero = 0; 428 const size_t zero = 0;
429 int rc; 429 int rc;
430 #if HAVE_GETADDRINFO 430 #if HAVE_GETADDRINFO
431 struct addrinfo hints, *res, *tmp; 431 struct addrinfo hints, *res, *tmp;
432 char servname[20]; 432 char servname[20];
433 #else 433 #else
484 * value will not be really used by the C 484 * value will not be really used by the C
485 * library. 485 * library.
486 */ 486 */
487 hints.ai_socktype = SOCK_STREAM; 487 hints.ai_socktype = SOCK_STREAM;
488 rc = getaddrinfo(dns_params->hostname, servname, &hints, &res); 488 rc = getaddrinfo(dns_params->hostname, servname, &hints, &res);
489 write(child_out, &rc, sizeof(rc));
489 if (rc != 0) { 490 if (rc != 0) {
490 write(child_out, &rc, sizeof(rc));
491 close(child_out); 491 close(child_out);
492 if (show_debug) 492 if (show_debug)
493 fprintf(stderr,"dns[%d] Error: getaddrinfo returned %d\n", 493 fprintf(stderr,"dns[%d] Error: getaddrinfo returned %d\n",
494 getpid(), rc); 494 getpid(), rc);
495 dns_params->hostname[0] = '\0'; 495 dns_params->hostname[0] = '\0';
496 continue; 496 continue;
497 } 497 }
498 write(child_out, &zero, sizeof(zero));
499 tmp = res; 498 tmp = res;
500 while (res) { 499 while (res) {
501 size_t ai_addrlen = res->ai_addrlen; 500 size_t ai_addrlen = res->ai_addrlen;
502 write(child_out, &ai_addrlen, sizeof(ai_addrlen)); 501 write(child_out, &ai_addrlen, sizeof(ai_addrlen));
503 write(child_out, res->ai_addr, res->ai_addrlen); 502 write(child_out, res->ai_addr, res->ai_addrlen);
520 sin.sin_family = hp->h_addrtype; 519 sin.sin_family = hp->h_addrtype;
521 } else 520 } else
522 sin.sin_family = AF_INET; 521 sin.sin_family = AF_INET;
523 522
524 sin.sin_port = htons(dns_params->port); 523 sin.sin_port = htons(dns_params->port);
525 write(child_out, &zero, sizeof(zero));
526 write(child_out, &addrlen, sizeof(addrlen)); 524 write(child_out, &addrlen, sizeof(addrlen));
527 write(child_out, &sin, addrlen); 525 write(child_out, &sin, addrlen);
528 write(child_out, &zero, sizeof(zero)); 526 write(child_out, &zero, sizeof(zero));
529 #endif 527 #endif
530 dns_params->hostname[0] = '\0'; 528 dns_params->hostname[0] = '\0';