[riot-notifications] [RIOT-OS/RIOT] pkg/openwsn/sock: fix sock_udp_close handling (#15838)

Francisco notifications at github.com
Fri Jan 22 15:42:30 CET 2021

### Contribution description

There where two problems related to the implementation of `sock_udp_close`:

1. messages where not removed from the mailbox and therefore not removed from `openqueue` after closing a `sock`
2. possible race conditions if a `sock` was closed while iterating through its linked 

Added a unittest for 1 and add check to make sure the mbox is empty before closing.

Addressed 2 by wrapping linked list access with a mutex. I'm unsure if there is still a race condition if `sock_udp_close()` is called in an ISR or by a thread with higher priority just before the asynchronous callback happens.

### Testing procedure

- `make -C tests/pkg_openwsn_sock_udp/ flash test -j3`

- take a close look at the possible race condition
You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * tests/pkg_openwsn_sock_udp: add test for sock_udp_close
  * pkg/openwsn/sock: add mutex around linked list access
  * pkg/openwsn/sock: drop messages in mbox on close

-- File Changes --

    M pkg/openwsn/sock/openwsn_sock_udp.c (34)
    M tests/pkg_openwsn_sock_udp/main.c (20)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210122/c00d69b5/attachment.htm>

More information about the notifications mailing list