2291017-addrconfig.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. commit a46378f35d88b65b816774a43196ac9862692071
  2. author: dldmitry
  3. date: 2016-04-27T13:25:03+03:00
  4. revision: 2291017
  5. libevent: don't use ADDRCONFIG
  6. __BYPASS_CHECKS__
  7. --- libevent/http.c (index)
  8. +++ libevent/http.c (working tree)
  9. @@ -4424,12 +4424,33 @@ make_addrinfo(const char *address, ev_uint16_t port)
  10. char strport[NI_MAXSERV];
  11. int ai_result;
  12. + static const char* names[] = {
  13. + "127.0.0.1",
  14. + "::1",
  15. + "localhost",
  16. + "localhost.localdomain",
  17. + "localhost6",
  18. + "localhost6.localdomain6",
  19. + NULL
  20. + };
  21. + const char **name_ptr = names;
  22. + int name_exists = 0;
  23. +
  24. memset(&hints, 0, sizeof(hints));
  25. hints.ai_family = AF_UNSPEC;
  26. hints.ai_socktype = SOCK_STREAM;
  27. /* turn NULL hostname into INADDR_ANY, and skip looking up any address
  28. * types we don't have an interface to connect to. */
  29. - hints.ai_flags = EVUTIL_AI_PASSIVE|EVUTIL_AI_ADDRCONFIG;
  30. + hints.ai_flags = EVUTIL_AI_PASSIVE;
  31. + while (*name_ptr) {
  32. + const char* tmp = *name_ptr++;
  33. + if (evutil_ascii_strcasecmp(tmp, address) == 0) {
  34. + name_exists = 1;
  35. + break;
  36. + }
  37. + }
  38. + if (!name_exists)
  39. + hints.ai_flags |= EVUTIL_AI_ADDRCONFIG;
  40. evutil_snprintf(strport, sizeof(strport), "%d", port);
  41. if ((ai_result = evutil_getaddrinfo(address, strport, &hints, &ai))
  42. != 0) {