Overview
Comment: | Allow thread-unsafe getaddrinfo() with locks
Before, getaddrinfo() would not be used at all if it is not thread-safe. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
fae85e954fc530d9f70b76a57fe051e3 |
User & Date: | js on 2014-02-27 22:40:33 |
Other Links: | manifest | tags |
Context
2014-02-28
| ||
00:38 | threading.h: Add of_once() check-in: ba5e756264 user: js tags: trunk | |
2014-02-27
| ||
22:40 | Allow thread-unsafe getaddrinfo() with locks check-in: fae85e954f user: js tags: trunk | |
2014-02-26
| ||
18:38 | Minor style change - no functional change check-in: e67130bd2d user: js tags: trunk | |
Changes
Modified src/resolver.m from [1037374b48] to [f6383b3c0c].
︙ | ︙ | |||
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; /* |
︙ | ︙ |