mbedmicro/mbed — pull request #46 by adamgreen (2013-08-29 06:24:15+00:00)
Title: Robustness fixes for netstack

It turns out that my previous concern about my semaphore token count overflow was well founded. Pablo was running a HTTP server with those changes and it performed horribly. It turned out that his server was hosting content from the LocalFileSystem. The semihost requests to the mbed interface chip for these LocalFileSystem calls halt the CPU and cause it to miss some ethernet interrupts. With my previous fix attempt this led to the semaphore not being signaled enough times and in the end the ethernet driver started to perform as though it only had once packet receive buffer. The final result was increased packet loss. I have removed the semaphore from the receive path in the ethernet driver and switched to a signal. I also pulled the loop back into packet_rx() which will loop through all available packets when it is awaken by the signal.

The other changes include:
* Fully disable LWIP_ASSERTs by defining LWIP_NOASSERT macro in lwipopts.h
* Reset pbuf length when re-queueing on error. Previously the re-queued buffer size would have been adjusted to the size of the previously received packet instead of the full allocated size of the pbuf object.
* Enable the SYS_LIGHTWEIGHT_PROT macro in lwipopts.h. This is also a very big change! It turns out that a lot of the global data structures in lwIP weren't being protected by synchronization objects and therefore were not thread safe.
Please refer to the commit descriptions for more details on each of those changes.

Pablo Gindel has buddy tested these changes with the TCP/UDP code that he is developing. I have also tested these networking changes with a few samples that I have building with gcc4mbed and also the NET_1 test built and tested with the Python scripts in the mbed tree itself. I would run more of the tests from the mbed build system but they don't seem to work with GCC_ARM due to what I believe is a _sbrk() issue.

Thanks for considering these changes!