From 1cdaaf47bf071db52aa10cb3aebb8aff2997e051 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Tue, 19 Aug 2014 14:23:56 +0200 Subject: [PATCH] win32 port: call srand() in tcpip_thread, too since the random seed is stored per thread --- ports/win32/test.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ports/win32/test.c b/ports/win32/test.c index 3f26431..51aad8c 100644 --- a/ports/win32/test.c +++ b/ports/win32/test.c @@ -399,12 +399,18 @@ void dns_found(const char *name, ip_addr_t *addr, void *arg) void dns_dorequest(void *arg) { - char* dnsname = "3com.com"; + const char* dnsname = "3com.com"; ip_addr_t dnsresp; - LWIP_UNUSED_ARG(arg); + err_t err; + if (arg != NULL) { + dnsname = (const char*)arg; + } - if (dns_gethostbyname(dnsname, &dnsresp, dns_found, 0) == ERR_OK) { + err = dns_gethostbyname(dnsname, &dnsresp, dns_found, 0); + if (err == ERR_OK) { dns_found(dnsname, &dnsresp, 0); + } else { + printf("dns_dorequest(): dns_gethostbyname(%s) returned error: %d\n", dnsname, err); } } #endif /* LWIP_DNS_APP && LWIP_DNS */ @@ -415,7 +421,11 @@ apps_init() { #if LWIP_DNS_APP && LWIP_DNS /* wait until the netif is up (for dhcp, autoip or ppp) */ - sys_timeout(5000, dns_dorequest, NULL); + sys_timeout(500, dns_dorequest, NULL); + sys_timeout(500, dns_dorequest, "3com.com"); + sys_timeout(500, dns_dorequest, "3com.com"); + sys_timeout(500, dns_dorequest, "www.gmx.de"); + sys_timeout(500, dns_dorequest, "www.GMX.de"); #endif /* LWIP_DNS_APP && LWIP_DNS */ #if LWIP_CHARGEN_APP && LWIP_SOCKET @@ -485,6 +495,9 @@ test_init(void * arg) init_sem = (sys_sem_t*)arg; #endif /* NO_SYS */ + /* init randomizer again (seed per thread) */ + srand(time(0)); + /* init network interfaces */ msvc_netif_init();