1

In my code I am using the code as follows.

do
{
    r = getaddrinfo(host, service, &hints, ret);
}
while (r == EAI_AGAIN);

when testing getaddrinfo() continuously fails thus loop not terminates properly.

Do you see any way to improve the code? can we use counter to count for number of times it should loop?

Also please let me know for what are all the reasons "EAI_AGAIN" returned by getaddrinfo() call.

Robᵩ
  • 163,533
  • 20
  • 239
  • 308
Naga
  • 487
  • 2
  • 7
  • 23
  • 3
    Error means: A temporary failure in name resolution occurred. Impossible for us to know why that happens for you. We don't know anything about the parameters that you pass. Calling this in a busy loop is unlikely to yield results. – David Heffernan Feb 21 '12 at 14:51
  • This most likely means some DNS servers are unreachable/down or your DNS is misconfigured. – Nemo Feb 21 '12 at 17:28

1 Answers1

0

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.

ekhumoro
  • 115,249
  • 20
  • 229
  • 336
John Carter
  • 460
  • 3
  • 10