[riot-notifications] [RIOT-OS/RIOT] pkg/semtech-loramac: fix deadlock when sending unconfirmed messages (#11535)

Alexandre Abadie notifications at github.com
Thu May 16 17:29:06 CEST 2019

The RIOT community cares a lot about code quality.
Therefore, before describing what your contribution is about, we would like
you to make sure that your modifications are compliant with the RIOT
coding conventions, see https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions.

### Contribution description

This PR is attempt to fix #11530. Even if the problem was well explained in #11530, I had a hard time figuring out what was going on with the messages exchanged between the MAC and the caller thread in the loramac adaption code. I end up to the conclusion that one TX done message should'nt be sent from the mcps_confirm event callback, as it was received by the semtech-loramac_recv function. And in the case of data effectively received, the RX message was blocking the event loop. On the next send, calling the send function in the mac, which is using a msg_send_receive, was causing the deadlock.

The proposed solution in this PR is to use a background timer to send a TX done message to the MAC thread after an amount time enough to ensure received data are processed in `semtech-loramac_recv`. This message, is not sent anymore from the mcps_confirm event. The RX message is then correctly retrieved by the caller thread. And no deadlock on future sends.
For me, it's working quite reliably now with this.

I tried other solutions, like setting a message queue to the caller thread but I found this was a workaround not really fixing the original issue.

Maybe there's a better fix that I didn't think of, suggestions are welcome.

@ParksProjets would you like to have a look ang give some feedback ?

Put here the description of your contribution:
- describe which part(s) of RIOT is (are) involved
- if it's a bug fix, describe the bug that it solves and how it is solved
- you can also give more information to reviewers about how to test your changes

### Testing procedure

Details steps to test your contribution:
- which test/example to compile for which board and is there a 'test' command
- how to know that it was not working/available in master
- the expected success test output

### Issues/PRs references

Examples: Fixes #1234. See also #5678. Depends on PR #9876.

Please use keywords (e.g., fixes, resolve) with the links to the issues you
resolved, this way they will be automatically closed when your pull request
is merged. See https://help.github.com/articles/closing-issues-using-keywords/.

You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * pkg/semtech-loramac: improve debugging messages
  * pkg/semtech-loramac: fix deadlock with uncnf tx mode

-- File Changes --

    M pkg/semtech-loramac/contrib/semtech_loramac.c (51)

-- 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/20190516/5ae12079/attachment.html>

More information about the notifications mailing list