I am writing a C program using LwIP with FreeRTOS for an embedded device, the micro-controller is Atmel AVR32.
In LwIP, after setting up the udp receive callback function by udp_recv(), I know that the callback function will be called once an UDP datagram is received. Then I can do something like process_udp_packet() inside the callback function. However, if there is another UDP packet received before the callback function finished, will this second packet queued in a buffer? Or the callback function will be called again immediately, even the first callback function is not finished?
Thank you very much.
Callback is called in context of LwIP itself. So, until you exit from callback, LwIP will be blocked. It will not process any new packets at all.
If there will be arriving new data, interface driver should not read it from interface (like modem) or save it in own buffer, until LwIP will be unblocked.
So, callback should exit as soon as possible to do not interfere normal LwIP workflow.
Best approach in programming of such callback functions is to read new packet into app queue and immediately return from callback. Then app in its own context can process new data.
But, if data processing is done really fast, you can do it inside callback function.