[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] gethostbyname() fails on the FireBee


After recompiling ping, I noticed that gethostbyname() fails to do DNS lookups on the FireBee. I suspect it is a timing problem.

See the attached testcase. It just does a simple gethostbyname().

On the FireBee, it is extremely strange:
- if I run it normally, it fails
- but if I run it with strace, it succeeds!

On ARAnyM, it always works.

I sniffed the packets, here is what happens when it fails:
- the DNS request is sent 3 times, very quickly
- as a result, the DNS server answers 3 times
- then FreeMiNT answers an ICMP "Port unreachable", 3 times

It looks like FreeMiNT sends a DNS request, then quickly closes the socket and retries, before the answer is received. However, ping works fine with IP addresses or static hosts put in /etc/hosts. This is not surprising as such cases don't produce DNS lookups.

The fact it works fine on the FireBee with strace is very weird. This is why I suspect a timing problem.
In the case where it works, strace outputs:
- Fconnect
- Fsento
- Fpoll
- Frecvfrom

That Fpoll() reminds me some recent select() issues in the kernel.
Could it be related?

Maybe something is too fast or wrong in mintv4e.prg...

Alan and others, do you have any idea?

NB: I compile with MiNTLib CVS-20140312.

Vincent Rivière
 * Compile with:
 * m68k-atari-mint-gcc -Wall gethost.c -o gethost

#include <stdio.h>
#include <netdb.h>

int main(void)
	const char* hostname = "atari.org";

	if (!gethostbyname(hostname))
		printf("%s: %s\n", hostname, hstrerror(h_errno));
		return 1;
		printf("%s: OK\n", hostname);
		return 0;