Merge pull request #174 from tycho/macos-unbreak-getaddrinfo

macos: use AI_UNUSABLE hint for getaddrinfo()
pull/179/head
David Schweikert 5 years ago committed by GitHub
commit 589d326650
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -80,6 +80,17 @@ extern "C" {
#include <sys/select.h> #include <sys/select.h>
/*** compatibility ***/
/* Mac OS X's getaddrinfo() does not fail if we use an invalid combination,
* e.g. AF_INET6 with "127.0.0.1". If we pass AI_UNUSABLE to flags, it behaves
* like other platforms. But AI_UNUSABLE isn't available on other platforms,
* and we can safely use 0 for flags instead.
*/
#ifndef AI_UNUSABLE
#define AI_UNUSABLE 0
#endif
/*** externals ***/ /*** externals ***/
extern char* optarg; extern char* optarg;
@ -2289,7 +2300,7 @@ void add_name(char* name)
/* getaddrinfo */ /* getaddrinfo */
bzero(&hints, sizeof(struct addrinfo)); bzero(&hints, sizeof(struct addrinfo));
hints.ai_flags = 0; hints.ai_flags = AI_UNUSABLE;
hints.ai_socktype = SOCK_RAW; hints.ai_socktype = SOCK_RAW;
hints.ai_family = hints_ai_family; hints.ai_family = hints_ai_family;
if (hints_ai_family == AF_INET) { if (hints_ai_family == AF_INET) {

Loading…
Cancel
Save