-
Notifications
You must be signed in to change notification settings - Fork 326
nrf_rpc: implement timeout for response #1764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@doki-nordic @grochu Friendly reminder to take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not having reviewed in shorter time, I hoped someone more experienced with nRF RPC could do it. Anyway the changes technically are OK to me, I just have some minor comments from the documentation perspective.
I started reviewing this PR, but since I have limited time to review it, I did not finalized it. I have concerns about mutex locking logic. Do we really need to lock it in context alloc function? When locking and unlocking logic is spread across multiple functions and multiple files, there is higher risk of edge cases or time races that may lead to dead lock. I am concern about context reusing functionality. Can you do simple context reusing test on this PR? See docs for some details about it: https://docs.nordicsemi.com/bundle/ncs-latest/page/nrfxlib/nrf_rpc/doc/architecture.html#id5 . This will happen, for example, when the local side sends a command and waits for a response, next the remote send another command back to local within the command handler context. In this case, context on local side should be reused. |
I'm happy to document it better, or rework this if you prefer locking the mutex in individual functions, but I thought doing this the current way actually simplifies the design - you always run nRF RPC code with the context mutex held and unlock it only when waiting for the peer or when releasing the context. And yeah, I can run a test like that :) |
6265956
to
f4b99f3
Compare
@grochu I addressed your comments, please take another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving to unblock development. Let's discuss the context locking with mutex later in another context.
cfe4b53
to
d4e34fe
Compare
d4e34fe
to
50ef472
Compare
Introduce necessary changes to support timing out waiting for a command response: 1. Handle nrf_rpc_os_msg_get() returning null data pointer, indicating that the response has not arrived within the required maximum time. 2. Introduce context mutex to protect all context members. This is necessary because now the response may arrive after the initiating thread has already released the context. Note that 2 may not sufficient solution to address another scenario where the context is freed by the initiator but is then reused before a delayed response arrives - to solve this, we likely need to introduce the concept of session ID or conversation ID to detect outdated packets. Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
50ef472
to
3084eae
Compare
Introduce necessary changes to support timing out waiting for a command response:
Note that 2 may not sufficient solution to address another scenario where the context is freed by the initiator but is then reused before a delayed response arrives - to solve this, we likely need to introduce the concept of session ID or conversation ID to detect outdated packets.
manifest-pr-skip