Browse Source

cast pthread name to char* for apple sdk

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/1727/head
R4SAS 3 years ago
parent
commit
ac25649425
  1. 36
      libi2pd/util.cpp

36
libi2pd/util.cpp

@ -124,7 +124,7 @@ namespace util @@ -124,7 +124,7 @@ namespace util
void SetThreadName (const char *name) {
#if defined(__APPLE__)
pthread_setname_np(name);
pthread_setname_np((char*)name);
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
pthread_set_name_np(pthread_self(), name);
#elif defined(__NetBSD__)
@ -384,12 +384,13 @@ namespace net @@ -384,12 +384,13 @@ namespace net
return boost::asio::ip::address::from_string("127.0.0.1");
#else
int af = (ipv6 ? AF_INET6 : AF_INET);
ifaddrs *addrs, *cur = nullptr;
if(getifaddrs(&addrs) == 0)
ifaddrs *addrs;
try
{
ifaddrs *addrs;
if (!getifaddrs(&addrs))
{
// got ifaddrs
cur = addrs;
while(cur)
for (auto cur = addrs; cur; cur = cur->ifa_next)
{
std::string cur_ifname(cur->ifa_name);
if (cur_ifname == ifname && cur->ifa_addr && cur->ifa_addr->sa_family == af)
@ -405,9 +406,14 @@ namespace net @@ -405,9 +406,14 @@ namespace net
std::string cur_ifaddr(addr);
return boost::asio::ip::address::from_string(cur_ifaddr);
}
cur = cur->ifa_next;
}
}
}
catch (std::exception& ex)
{
LogPrint(eLogError, "NetIface: Exception while searching address using ifaddr: ", ex);
}
if(addrs) freeifaddrs(addrs);
std::string fallback;
if(ipv6)
@ -483,12 +489,12 @@ namespace net @@ -483,12 +489,12 @@ namespace net
FREE(pAddresses);
return boost::asio::ip::address_v6 ();
#else
ifaddrs *addrs, *cur = nullptr;
auto err = getifaddrs(&addrs);
if (!err)
ifaddrs *addrs;
try
{
if (!getifaddrs(&addrs))
{
cur = addrs;
while(cur)
for (auto cur = addrs; cur; cur = cur->ifa_next)
{
if (cur->ifa_addr && cur->ifa_addr->sa_family == AF_INET6)
{
@ -501,9 +507,13 @@ namespace net @@ -501,9 +507,13 @@ namespace net
return boost::asio::ip::address_v6 (bytes);
}
}
cur = cur->ifa_next;
}
}
}
catch (std::exception& ex)
{
LogPrint(eLogError, "NetIface: Exception while searching Yggdrasill address using ifaddr: ", ex);
}
LogPrint(eLogWarning, "NetIface: Interface with Yggdrasil network address not found");
if(addrs) freeifaddrs(addrs);
return boost::asio::ip::address_v6 ();

Loading…
Cancel
Save