-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix(studio): Ensure putting framing byte when sending rpc #3215
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
If tx buffer became full when sending PRC response, framing byte can be skipped and communication gets stuck. This patch adds wait for putting EOF failure and adds error handling for putting SOF failure.
| LOG_ERR("RPC TX buffer full"); | ||
| k_mutex_unlock(&rpc_transport_mutex); | ||
| return -ENOMEM; | ||
| } |
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.
Treating SOF put failure as error sounds fine? I've never hit error here yet.
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.
I'm on the fence here, whether there should be any attempt to retry a few times, and then return -ENOMEM if that fails? Would give the underlying transport a chance to empty the ring buffer to free space. I'd suggest we try that.
In the case of a failure, I usually prefer, when locking involved, to create a new local at the top of the function int ret = 0; and then in this branch, set ret = -ENOMEM; goto exit and update the exit: to return ret instead.
petejohanson
left a comment
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.
Thanks for working on this! A few thoughts.
| LOG_ERR("RPC TX buffer full"); | ||
| k_mutex_unlock(&rpc_transport_mutex); | ||
| return -ENOMEM; | ||
| } |
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.
I'm on the fence here, whether there should be any attempt to retry a few times, and then return -ENOMEM if that fails? Would give the underlying transport a chance to empty the ring buffer to free space. I'd suggest we try that.
In the case of a failure, I usually prefer, when locking involved, to create a new local at the top of the function int ret = 0; and then in this branch, set ret = -ENOMEM; goto exit and update the exit: to return ret instead.
| framing_byte = FRAMING_EOF; | ||
| ring_buf_put(&rpc_tx_buf, &framing_byte, 1); | ||
| // If response is large, tx buffer can be full for async transport. | ||
| while (ring_buf_put(&rpc_tx_buf, &framing_byte, 1) == 0) { |
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.
This should ideally "give up" after a certain period/number of tries, and return, so we don't get stuck in an infinite loop, IMHO.
If tx buffer became full when sending PRC response, framing byte can be skipped and communication gets stuck. This patch adds wait for putting EOF failure and adds error handling for putting SOF failure.
I hit this error when sending keylayout data on BLE gatt. Waiting in the loop practically resolved the issue.
PR check-list