lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] Problem about outgoing connections


From: Hans Petter Selasky
Subject: Re: [lwip-devel] Problem about outgoing connections
Date: Thu, 17 Mar 2011 12:35:28 +0100
User-agent: KMail/1.13.5 (FreeBSD/8.2-PRERELEASE; KDE/4.4.5; amd64; ; )

On Monday 14 March 2011 11:40:10 Kieran Mansley wrote:
> On Mon, 2011-03-07 at 12:00 +0100, Hans Petter Selasky wrote:
> > Hi,
> > 
> > I'm using your LwIP stack in a multithreaded embedded project and it is
> > working very well. One problem however that has popped up is that when
> > creating an outgoing connection before the LwIP stack has a default
> > gateway and active link, "netconn_connect()" seems stuck and will never
> > return. Neither do we see any packets transmitted when the link is
> > finally up. I suspect someone has seen this issue before? How can this
> > be fixed/worked around?
> 
> This doesn't sound familiar, so either no one else has reported it or
> I've forgotten.  If you don't have a default route set up I'd expect the
> connect to immediately return with an error.  If you do have a route but
> no link I'd expect the connect to try to retransmit packets at
> increasing intervals until it either succeeds or times out (could take a
> long time to time out).  Your reported behaviour doesn't match either of
> these so I'd suggest digging deeper to find out where it is stuck, and
> file a bug.

Index: lwip/src/core/tcp_out.c
===================================================================
--- lwip/src/core/tcp_out.c     (revision 2831)
+++ lwip/src/core/tcp_out.c     (working copy)
@@ -697,6 +697,11 @@
   }
 #endif
 
+  /* Set retransmission timer running if it is not currently enabled.
+   * This must be set before checking the route. */
+  if (pcb->rtime == -1)
+       pcb->rtime = 0;
+
   /* If we don't have a local IP address, we get one by
      calling ip_route(). */
   if (ip_addr_isany(&(pcb->local_ip))) {
@@ -707,10 +712,6 @@
     ip_addr_set(&(pcb->local_ip), &(netif->ip_addr));
   }
 
-  /* Set retransmission timer running if it is not currently enabled */
-  if(pcb->rtime == -1)
-    pcb->rtime = 0;
-
   if (pcb->rttest == 0) {
     pcb->rttest = tcp_ticks;
     pcb->rtseq = ntohl(seg->tcphdr->seqno);

The connection hang because there was no route, and the timer was not started. 
The patch above solved the problem for me! Does this look OK to you?

--HPS



reply via email to

[Prev in Thread] Current Thread [Next in Thread]