Skip to content

Commit

Permalink
restarts cloud_manager only when user invokes oc_cloud_manager_starts
Browse files Browse the repository at this point in the history
  • Loading branch information
jkralik committed Dec 27, 2023
1 parent 28f8878 commit 9f6ca38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions api/cloud/oc_cloud.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ cloud_update_by_resource(oc_cloud_context_t *ctx,
return;
}

if (oc_cloud_manager_start(ctx, ctx->callback, ctx->user_data) != 0) {
OC_CLOUD_ERR("cannot start cloud manager");
}
// if (oc_cloud_manager_start(ctx, ctx->callback, ctx->user_data) != 0) {
// OC_CLOUD_ERR("cannot start cloud manager");
// }
}

#ifdef OC_SESSION_EVENTS
Expand Down
5 changes: 4 additions & 1 deletion api/cloud/oc_cloud_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,9 +615,9 @@ cloud_manager_login_handler(oc_client_response_t *data)
bool handleUnauthorizedByRefresh = cloud_context_has_refresh_token(ctx);
oc_cps_t cps = OC_CPS_FAILED;
oc_cloud_error_t err = _login_handler(ctx, data, &cps);
oc_reset_delayed_callback(ctx, cloud_manager_callback_handler_async, 0);
if ((ctx->store.status & OC_CLOUD_REGISTERED) == 0) {
cloud_set_cps_and_last_error(ctx, cps, err);
oc_reset_delayed_callback(ctx, cloud_manager_callback_handler_async, 0);
return;
}
if (err == CLOUD_OK) {
Expand All @@ -631,6 +631,7 @@ cloud_manager_login_handler(oc_client_response_t *data)
refresh_token_expires_in_ms(ctx->store.expires_in *
MILLISECONDS_PER_SECOND));
}
oc_reset_delayed_callback(ctx, cloud_manager_callback_handler_async, 0);
return;
}
ctx->store.status |= OC_CLOUD_FAILURE;
Expand All @@ -640,6 +641,7 @@ cloud_manager_login_handler(oc_client_response_t *data)
OC_CLOUD_DBG("Login failed with error(%d), retrying", (int)err);
// While retrying, keep last error (clec) to CLOUD_OK
cloud_set_cps_and_last_error(ctx, cps, CLOUD_OK);
oc_reset_delayed_callback(ctx, cloud_manager_callback_handler_async, 0);
return;
}
if (err == CLOUD_ERROR_UNAUTHORIZED) {
Expand All @@ -654,6 +656,7 @@ cloud_manager_login_handler(oc_client_response_t *data)
cloud_context_clear(ctx);
}
}
oc_reset_delayed_callback(ctx, cloud_manager_callback_handler_async, 0);
return;
}
cloud_set_cps_and_last_error(ctx, cps, err);
Expand Down

0 comments on commit 9f6ca38

Please sign in to comment.