[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AW: [lwip-devel] Semaphores and socket.c's event_callback
From: |
Goldschmidt Simon |
Subject: |
AW: [lwip-devel] Semaphores and socket.c's event_callback |
Date: |
Thu, 25 Oct 2007 13:00:21 +0200 |
Hi,
> src/api/sockets.c uses a semaphore (selectsem) for protecting
> critical sections of select(). The result is that event_callback()
> may want to sleep, which is a problem if one wants to call
event_callback()
> from an interrupt handler for instance.
Calling event_callback from an interrupt handler is not supported!
The reason for this is that it would imply calling ip_input() from an
interrupt
handler, which is also not supported: the lwIP core is not protected
against
concurrent access: ip_input() would perhaps enter tcp_input() which
shares
states with tcp_output(), so entering tcp_input() from interrupt context
while the normal context is sending a TCP packet could lead to undefined
results!
> Since these are really only critical sections, here is a patch which
makes
> use of SYS_ARCH_PROTECT() which doesn't pose such problem.
As I said, your patch might work, but what you want to do is not
supported
anyway, so there's no need for such a patch.
The solution to this problem is calling tcpip_input() instead of
ip_input()
from your interrupt handler. Packets will be put on a queue and fed to
ip_input()
in the thread context of tcpip_thread.
Simon