Differences From Artifact [de3749afa6]:
- File
src/resolver.m
— part of check-in
[8aeee6680a]
at
2018-07-28 20:21:01
on branch trunk
— Add of_socket_address_ip_string()
This replaces of_address_to_string_and_port(). (user: js, size: 6815) [annotate] [blame] [check-ins using]
To Artifact [aa220e27b3]:
- File src/resolver.m — part of check-in [647ec47eda] at 2018-08-04 23:43:55 on branch trunk — OFDNSResolver: Improve error reporting (user: js, size: 7178) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
28 29 30 31 32 33 34 | #import "resolver.h" #import "macros.h" #if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) # include "threading.h" #endif | < > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #import "resolver.h" #import "macros.h" #if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) # include "threading.h" #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) # import "OFLockFailedException.h" # import "OFUnlockFailedException.h" #endif #import "OFResolveHostFailedException.h" #import "socket_helpers.h" #if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) static of_mutex_t mutex; OF_CONSTRUCTOR() |
︙ | ︙ | |||
71 72 73 74 75 76 77 | # if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) if (!of_mutex_lock(&mutex)) @throw [OFLockFailedException exception]; @try { # endif | < < | | | > > | | | > > > | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | # if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) if (!of_mutex_lock(&mutex)) @throw [OFLockFailedException exception]; @try { # endif if (getaddrinfo([host UTF8String], portCString, &hints, &res0) != 0) @throw [OFResolveHostFailedException exceptionWithHost: host recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN recordType: 0 error: OF_DNS_RESOLVER_ERROR_UNKNOWN]; count = 0; for (res = res0; res != NULL; res = res->ai_next) count++; if (count == 0) { freeaddrinfo(res0); @throw [OFResolveHostFailedException exceptionWithHost: host recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN recordType: 0 error: OF_DNS_RESOLVER_ERROR_NO_RESULT]; } if ((ret = calloc(count + 1, sizeof(*ret))) == NULL) { freeaddrinfo(res0); @throw [OFOutOfMemoryException exceptionWithRequestedSize: (count + 1) * sizeof(*ret)]; |
︙ | ︙ | |||
188 189 190 191 192 193 194 | ret[1] = NULL; return ret; } if ((he = gethostbyname((const void *)[host UTF8String])) == NULL || he->h_addrtype != AF_INET) | | > > | | | > > > | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | ret[1] = NULL; return ret; } if ((he = gethostbyname((const void *)[host UTF8String])) == NULL || he->h_addrtype != AF_INET) @throw [OFResolveHostFailedException exceptionWithHost: host recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN recordType: 0 error: OF_DNS_RESOLVER_ERROR_UNKNOWN]; count = 0; for (ip = (char **)he->h_addr_list; *ip != NULL; ip++) count++; if (count == 0) @throw [OFResolveHostFailedException exceptionWithHost: host recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN recordType: 0 error: OF_DNS_RESOLVER_ERROR_NO_RESULT]; if ((ret = calloc(count + 1, sizeof(*ret))) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: (count + 1) * sizeof(*ret)]; if ((results = malloc(count * sizeof(*results))) == NULL) { |
︙ | ︙ |