From cada8d324fb8f9fd99932e4e2322f12bfddcb713 Mon Sep 17 00:00:00 2001 From: oliverschmidt Date: Sun, 7 Jan 2007 13:52:25 +0000 Subject: [PATCH] Up to now the DNS resolver relied on the uIP 1/2 second polling for its retry management (implementing a linear back-off). But Contiki 2.x uIP doesn't implement the 1/2 second polling for UDP connections anymore! Therefore I added an event timer to the DNS resolver for its retry management. I went for a 1 second interval (still with the same linear back-off) as compromise between officially recommended longer intervals (i.e. BIND with 5 seconds and exponential back-off) and a reasonable user experience for the self induced packet loss in ARP setups. --- core/net/resolv.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/net/resolv.c b/core/net/resolv.c index 7a6167457..c373e21cf 100644 --- a/core/net/resolv.c +++ b/core/net/resolv.c @@ -57,7 +57,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: resolv.c,v 1.4 2006/09/18 23:30:40 oliverschmidt Exp $ + * $Id: resolv.c,v 1.5 2007/01/07 13:52:25 oliverschmidt Exp $ * */ @@ -133,6 +133,8 @@ static u8_t seqno; static struct uip_udp_conn *resolv_conn = NULL; +static struct etimer retry; + process_event_t resolv_event_found; PROCESS(resolv_process, "DNS resolver"); @@ -185,6 +187,7 @@ check_entries(void) namemapptr = &names[i]; if(namemapptr->state == STATE_NEW || namemapptr->state == STATE_ASKING) { + etimer_set(&retry, CLOCK_SECOND); if(namemapptr->state == STATE_ASKING) { if(--namemapptr->tmr == 0) { if(++namemapptr->retries == MAX_RETRIES) { @@ -328,7 +331,6 @@ newdata(void) --nanswers; } } - } /*-----------------------------------------------------------------------------------*/ /** \internal @@ -351,11 +353,15 @@ PROCESS_THREAD(resolv_process, ev, data) while(1) { PROCESS_WAIT_EVENT(); - if(ev == EVENT_NEW_SERVER) { + if(ev == PROCESS_EVENT_TIMER) { + if(resolv_conn != NULL) { + tcpip_poll_udp(resolv_conn); + } + + } else if(ev == EVENT_NEW_SERVER) { if(resolv_conn != NULL) { uip_udp_remove(resolv_conn); } - resolv_conn = udp_new((uip_ipaddr_t *)data, HTONS(53), NULL); } else if(ev == tcpip_event) {