aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Bogomolov <bogomolov@google.com>2024-07-17 17:37:57 +0000
committerDmitry Vyukov <dvyukov@google.com>2024-07-17 18:01:31 +0000
commit0f90262589ccdf81ff02549bb70e898886f75852 (patch)
treebbe3899e47ddb1ae96e95cbbc66f78c3d084dba7
parent4403a757953225e9180ed7893c2b2e4ee8569766 (diff)
executor: manually replace localhost with equivalent ipv4/6 address
It should fix errors like this one: SYZFAIL: failed to resolve manager addr addr=localhost h_errno=2 (errno 11: Resource temporarily unavailable
-rw-r--r--executor/conn.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/executor/conn.h b/executor/conn.h
index 1a329a246..cf099346c 100644
--- a/executor/conn.h
+++ b/executor/conn.h
@@ -96,6 +96,7 @@ private:
static int Connect(const char* addr, const char* ports)
{
int port = atoi(ports);
+ bool localhost = !strcmp(addr, "localhost");
if (!strcmp(addr, "stdin"))
return STDIN_FILENO;
if (port == 0)
@@ -103,11 +104,15 @@ private:
sockaddr_in saddr4 = {};
saddr4.sin_family = AF_INET;
saddr4.sin_port = htons(port);
+ if (localhost)
+ addr = "127.0.0.1";
if (inet_pton(AF_INET, addr, &saddr4.sin_addr))
return Connect(&saddr4, &saddr4.sin_addr, port);
sockaddr_in6 saddr6 = {};
saddr6.sin6_family = AF_INET6;
saddr6.sin6_port = htons(port);
+ if (localhost)
+ addr = "0:0:0:0:0:0:0:1";
if (inet_pton(AF_INET6, addr, &saddr6.sin6_addr))
return Connect(&saddr6, &saddr6.sin6_addr, port);
auto* hostent = gethostbyname(addr);