Skip to content
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

Error handling with retries in blockwise upload #489

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rashmivaidya72
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented May 9, 2024

Visit the preview URL for this PR (updated for commit 929951b):

https://golioth-firmware-sdk-doxygen-dev--pr489-rsv-handle-upl-g63df03m.web.app

(expires Tue, 21 May 2024 04:12:54 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: a9993e61697a3983f3479e468bcb0b616f9a0578

Copy link

github-actions bot commented May 9, 2024

Code Coverage

Type Coverage
lines 50.7% (1054 of 2078 lines)
functions 52.5% (95 of 181 functions)

Signed-off-by: Rashmi Vaidya <rashmi.vaidya72@gmail.com>
{
// TODO: handle errors like disconnects etc
return GOLIOTH_OK;
while (1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check (and decrement) the retry count here in the while(). I also don't think we need to keep retry_count in the context struct.

@@ -134,10 +188,16 @@ enum golioth_status golioth_blockwise_post(struct golioth_client *client,
read_block_cb cb,
void *callback_arg)
{
enum golioth_status status = GOLIOTH_ERR_FAIL;
enum golioth_status status;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be declared closer to use.

{
status = upload_single_block(client, ctx);
upload_single_block(client, ctx);
if (ctx->status == GOLIOTH_OK)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels confusing to be mixing storing the status in the context and keeping it local on the stack. I'm not sure that we need it in the context struct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. The status in the context struct is used to store the status that we get from the server response that is passed to us via a callback executed on the CoAP client thread. But because we are doing synchronous operations, the server response status is also returned to us directly, so we don't even actually need the callback.

On the other hand, the synchronous functions internal to the coap client create and destroy a semaphore for each transaction (i.e. for each block that we download). It would be more efficient to use asynchronous transfers and to make the operations blocking by waiting on a semaphore that is managed by the blockwise transfers module and created once per blockwise transfer.

if (ctx->status == GOLIOTH_OK)
{
ctx->offset++;
}
else
{
// TODO: handle_upload_error
status = handle_upload_error();
status = handle_upload_error(client, ctx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we fall into the else clause we never increment the offset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants