Description
Description
- Type: Bug
- Priority: Major
Bug
meed-os sha:
8f29517: Merge pull request #4317 from c1728p9/reduce_test_overhead
(i.e. current master
)
Expected behavior
Sockets should not register callbacks (on state change events) which are not allowed to be executed in interrupt context.
Actual behavior
In method Socket::open()
the virtual method Socket::event()
gets registered as callback on state change of the socket. The API spec for NetworkStack::socket_attach()
says:
The callback may be called in an interrupt context and should not perform expensive operations such as recv/send calls.
Unfortunately, both TCPSocket::event()
and UDPSocket::event()
call Semaphore::wait(0)
which is not allowed to be called in interrupt context (following the CMSIS-RTOS specs for osSemaphoreWait()
). This call consequently returns -1
rather than the number of available tokens causing (possibly erroneously) the release of the semaphore.