>
> > This loop happens to be circular! Should I assume that I'm calling
> > some lwip tcp function from a context that has not been properly
> > guarded with mutexes?
>
> Yes.  Almost certainly you have a race between two threads, or perhaps
> between your application thread and the timers, that you haven't
> protected sufficiently.  As a result, they will both occasionally try
> and modify a queue at the same time, and it will become corrupt,
> containing a circular reference for example as you point out.
>
> > 2. The second issue that I see (if I don't run into issue 1), is that
> > the TX performance keeps dropping slowly. Over 10 minutes it drops
> > about 10 Mbps or so..starting from lets say 55 Mbps to 45 Mbps, and
> > continuing to drop. Any suggestions on what to look for here? Could it
> > be that my timer interval is not quite right?
>
> Firstly I would make sure you've solved issue 1.  I wouldn't have
> thought the timer interval was to blame for dropping performance.  I
> think someone else has reported something similar recently but couldn't
> get to the bottom of it and I can't remember the details now.
> Personally I think it is most likely to be a memory leak or something
> like that leading to a shortage of packet buffers or something like
> that.  A corrupt queue could be to blame though (if it just kept getting
> longer and longer, and we have to iterate it each time a packet is
> received for example).
>
>
Thanks a ton, Kieran. You were absolutely correct on both counts.

My application was structured as follows:

while (1) {
        ethernetif_input(netif);
        transfer_data()
}


What was happening was that ethernetif_input (based on the template in
netif/ethernetif.c), takes input data from a queue and sends it to ip_input.
When this is happening, a timer interrupt occurred, that called tcp_output
within tcp_slowtmr.

I put in a big global lock around "ethernetif_input" in the above while
loop, and now I see that everything works fine - consistent speeds and no
degradation over time.

What I have not yet understood is that the template ethernetif_input doesn't
talk about protecting calls to ip/tcp functions from within that function.
Should calls to ip_input be protected via a mutex? It seemed to me that most
of the critical functions inside lwip were protected, so I assumed that a
timer interrupt could happen when lwip is processing tcp input. However this
does not seem to be the case. Do you have any thoughts on that?

Thanks,
-Siva
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to