Skip to content

[NETSOCKET] TCPSocket & UDPSocket event handler cannot be run in IRQ context #4343

Closed
@betzw

Description

@betzw

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions