Differences From Artifact [1037374b48]:
- File src/resolver.m — part of check-in [fab07a40ca] at 2014-02-12 03:17:01 on branch trunk — Fix compilation with mingw32 (user: js, size: 7506) [annotate] [blame] [check-ins using]
To Artifact [f6383b3c0c]:
- File
src/resolver.m
— part of check-in
[fae85e954f]
at
2014-02-27 22:40:33
on branch trunk
— Allow thread-unsafe getaddrinfo() with locks
Before, getaddrinfo() would not be used at all if it is not thread-safe. (user: js, size: 7805) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
55 56 57 58 59 60 61 | of_resolver_result_t** of_resolve_host(OFString *host, uint16_t port, int type) { of_resolver_result_t **ret, **retIter; of_resolver_result_t *results, *resultsIter; size_t count; | | > > > > > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | of_resolver_result_t** of_resolve_host(OFString *host, uint16_t port, int type) { of_resolver_result_t **ret, **retIter; of_resolver_result_t *results, *resultsIter; size_t count; #ifdef HAVE_GETADDRINFO struct addrinfo hints = { 0 }, *res, *res0; char portCString[7]; hints.ai_family = AF_UNSPEC; hints.ai_socktype = type; hints.ai_flags = AI_NUMERICSERV; snprintf(portCString, 7, "%" PRIu16, port); # if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) if (!of_mutex_lock(&mutex)) @throw [OFLockFailedException exception]; # endif if (getaddrinfo([host UTF8String], portCString, &hints, &res0)) @throw [OFAddressTranslationFailedException exceptionWithHost: host]; count = 0; for (res = res0; res != NULL; res = res->ai_next) |
︙ | ︙ | |||
99 100 101 102 103 104 105 106 107 108 109 110 111 112 | resultsIter->addressLength = res->ai_addrlen; *retIter = resultsIter; } *retIter = NULL; ret[0]->private_ = res0; #else struct hostent *he; in_addr_t s_addr; char **ip; struct sockaddr_in *addrs, *addrsIter; /* | > > > > > | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | resultsIter->addressLength = res->ai_addrlen; *retIter = resultsIter; } *retIter = NULL; ret[0]->private_ = res0; # if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) if (!of_mutex_unlock(&mutex)) @throw [OFUnlockFailedException exception]; # endif #else struct hostent *he; in_addr_t s_addr; char **ip; struct sockaddr_in *addrs, *addrsIter; /* |
︙ | ︙ |