Skip to content

Commit

Permalink
Merge pull request schweikert#174 from tycho/macos-unbreak-getaddrinfo
Browse files Browse the repository at this point in the history
macos: use AI_UNUSABLE hint for getaddrinfo()
  • Loading branch information
schweikert authored Feb 29, 2020
2 parents 43767e2 + 5187f5b commit 589d326
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/fping.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ extern "C" {

#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 ***/

extern char* optarg;
Expand Down Expand Up @@ -2289,7 +2300,7 @@ void add_name(char* name)

/* getaddrinfo */
bzero(&hints, sizeof(struct addrinfo));
hints.ai_flags = 0;
hints.ai_flags = AI_UNUSABLE;
hints.ai_socktype = SOCK_RAW;
hints.ai_family = hints_ai_family;
if (hints_ai_family == AF_INET) {
Expand Down

0 comments on commit 589d326

Please sign in to comment.