在我的代码中,我使用的代码如下。
do
{
r = getaddrinfo(host, service, &hints, ret);
}
while (r == EAI_AGAIN);
当测试 getaddrinfo() 连续失败时,循环不会正确终止。
你有什么方法可以改进代码吗?我们可以使用计数器来计算它应该循环的次数吗?
另外请让我知道 getaddrinfo() 调用返回“EAI_AGAIN”的所有原因。
在我的代码中,我使用的代码如下。
do
{
r = getaddrinfo(host, service, &hints, ret);
}
while (r == EAI_AGAIN);
当测试 getaddrinfo() 连续失败时,循环不会正确终止。
你有什么方法可以改进代码吗?我们可以使用计数器来计算它应该循环的次数吗?
另外请让我知道 getaddrinfo() 调用返回“EAI_AGAIN”的所有原因。
Here is, admittedly, a wild guess.
We're also seeing this on a slightly underpowered single core embedded system.
I assume (in our case dnsmasq) is running in a separate process, and for whatever reason (probably because we're running around in circles chasing our tails) it doesn't get enough resources (cpu/ram/...) to do its job.
A wild guess at a solution might be to put a sleep into that tight loop and let the DNS caching magic at the resources it needs to do it's work.
I will let you know if it works.