asan test suite fix
This commit is contained in:
parent
fd69efa45c
commit
2c4862e0f1
@ -69,13 +69,14 @@ namespace ix
|
|||||||
Logger() << msg;
|
Logger() << msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getAnyFreePort()
|
int getAnyFreePortSimple()
|
||||||
{
|
{
|
||||||
// ASAN complains about getsockname
|
|
||||||
#if defined(__has_feature) && __has_feature(address_sanitizer)
|
|
||||||
static int defaultPort = 8090;
|
static int defaultPort = 8090;
|
||||||
return defaultPort++;
|
return defaultPort++;
|
||||||
#else
|
}
|
||||||
|
|
||||||
|
int getAnyFreePort()
|
||||||
|
{
|
||||||
int defaultPort = 8090;
|
int defaultPort = 8090;
|
||||||
int sockfd;
|
int sockfd;
|
||||||
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||||
@ -120,15 +121,21 @@ namespace ix
|
|||||||
::close(sockfd);
|
::close(sockfd);
|
||||||
|
|
||||||
return port;
|
return port;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int getFreePort()
|
int getFreePort()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
#if defined(__has_feature)
|
||||||
|
# if __has_feature(address_sanitizer)
|
||||||
|
int port = getAnyFreePortSimple();
|
||||||
|
# else
|
||||||
int port = getAnyFreePort();
|
int port = getAnyFreePort();
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
int port = getAnyFreePort();
|
||||||
|
#endif
|
||||||
//
|
//
|
||||||
// Only port above 1024 can be used by non root users, but for some
|
// Only port above 1024 can be used by non root users, but for some
|
||||||
// reason I got port 7 returned with macOS when binding on port 0...
|
// reason I got port 7 returned with macOS when binding on port 0...
|
||||||
|
Loading…
Reference in New Issue
Block a user