Fix high CPU usage on 5XX error codes

This commit is contained in:
Nicolas Werner 2020-03-22 20:33:15 +01:00
parent 7df6529310
commit 7a2b996f18
1 changed files with 5 additions and 26 deletions

View File

@ -974,36 +974,15 @@ ChatPage::trySync()
const auto err_code = mtx::errors::to_string(err->matrix_error.errcode); const auto err_code = mtx::errors::to_string(err->matrix_error.errcode);
const int status_code = static_cast<int>(err->status_code); const int status_code = static_cast<int>(err->status_code);
if (status_code <= 0 || status_code >= 600) { if (http::is_logged_in() && err->matrix_error.errcode ==
if (!http::is_logged_in()) mtx::errors::ErrorCode::M_UNKNOWN_TOKEN) {
return; emit dropToLoginPageCb(msg);
emit tryDelayedSyncCb();
return; return;
} }
nhlog::net()->error("sync error: {} {}", status_code, err_code); nhlog::net()->error("sync error: {} {}", status_code, err_code);
emit tryDelayedSyncCb();
switch (status_code) { return;
case 502:
case 504:
case 524: {
emit trySyncCb();
return;
}
default: {
if (!http::is_logged_in())
return;
if (err->matrix_error.errcode ==
mtx::errors::ErrorCode::M_UNKNOWN_TOKEN)
emit dropToLoginPageCb(msg);
else
emit tryDelayedSyncCb();
return;
}
}
} }
nhlog::net()->debug("sync completed: {}", res.next_batch); nhlog::net()->debug("sync completed: {}", res.next_batch);