|
From: | David Empson |
Subject: | Re: [lwip-users] current_iphdr_* + loopif = non-reentrant code |
Date: | Fri, 20 May 2011 10:27:38 +1200 |
Hi Luca
Your analysis of what went wrong is correct, but it
is not a bug in LWIP. Your usage of LWIP is at fault.
For all versions of LWIP, the core is not
reentrant.
In this case you have your main loop invoking LWIP
and an interrupt attempting to invoke LWIP before it has returned to the main
loop, which results in two parts of the LWIP core executing at the same time,
with attendant risks of overwriting global variables or other state information.
If it worked before, you probably got lucky because UDP has less state
information than TCP, so less that can go wrong due to reentancy.
For NO_SYS = 1, the best solution is usually to
have your Ethernet interrupt not directly call LWIP, but instead do
something like set a flag which is picked up by the main loop to process
incoming Ethernet packets.
An alternative is to lock out your Ethernet
interrupt (or all interrupts) around all calls to any LWIP function invoked from
the main loop (or from any code called by the main loop). Just blocking
interrupts for lwip_poll() is not sufficient. You would also have to block
interrupts during any calls which transmit data, open or close PCBs,
etc.
----- Original Message -----
|
[Prev in Thread] | Current Thread | [Next in Thread] |