| 516 | */ |
| 517 | |
| 518 | http_addrlist_t * /* O - List of addresses or NULL */ |
| 519 | httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for passive listen address */ |
| 520 | int family, /* I - Address family or AF_UNSPEC */ |
| 521 | const char *service) /* I - Service name or port number */ |
| 522 | { |
| 523 | http_addrlist_t *first, /* First address in list */ |
| 524 | *addr, /* Current address in list */ |
| 525 | *temp; /* New address */ |
| 526 | char ipv6[64], /* IPv6 address */ |
| 527 | *ipv6zone; /* Pointer to zone separator */ |
| 528 | int ipv6len; /* Length of IPv6 address */ |
| 529 | _cups_globals_t *cg = _cupsGlobals(); |
| 530 | /* Global data */ |
| 531 | |
| 532 | |
| 533 | #ifdef DEBUG |
| 534 | _cups_debug_printf("httpAddrGetList(hostname=\"%s\", family=AF_%s, " |
| 535 | "service=\"%s\")\n", |
| 536 | hostname ? hostname : "(nil)", |
| 537 | family == AF_UNSPEC ? "UNSPEC" : |
| 538 | # ifdef AF_LOCAL |
| 539 | family == AF_LOCAL ? "LOCAL" : |
| 540 | # endif /* AF_LOCAL */ |
| 541 | # ifdef AF_INET6 |
| 542 | family == AF_INET6 ? "INET6" : |
| 543 | # endif /* AF_INET6 */ |
| 544 | family == AF_INET ? "INET" : "???", service); |
| 545 | #endif /* DEBUG */ |
| 546 | |
| 547 | httpInitialize(); |
| 548 | |
| 549 | #ifdef HAVE_RES_INIT |
| 550 | /* |
| 551 | * STR #2920: Initialize resolver after failure in cups-polld |
| 552 | * |
| 553 | * If the previous lookup failed, re-initialize the resolver to prevent |
| 554 | * temporary network errors from persisting. This *should* be handled by |
| 555 | * the resolver libraries, but apparently the glibc folks do not agree. |
| 556 | * |
| 557 | * We set a flag at the end of this function if we encounter an error that |
| 558 | * requires reinitialization of the resolver functions. We then call |
| 559 | * res_init() if the flag is set on the next call here or in httpAddrLookup(). |
| 560 | */ |
| 561 | |
| 562 | if (cg->need_res_init) |
| 563 | { |
| 564 | res_init(); |
| 565 | |
| 566 | cg->need_res_init = 0; |
| 567 | } |
| 568 | #endif /* HAVE_RES_INIT */ |
| 569 | |
| 570 | /* |
| 571 | * Lookup the address the best way we can... |
| 572 | */ |
| 573 | |
| 574 | first = addr = NULL; |
| 575 | |