Fix high CPU usage on 5XX error codes

pull/156/head
Nicolas Werner 5 years ago
parent 7df6529310
commit 7a2b996f18
  1. 27
      src/ChatPage.cpp

@ -974,37 +974,16 @@ 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);
switch (status_code) {
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(); emit tryDelayedSyncCb();
return; return;
} }
}
}
nhlog::net()->debug("sync completed: {}", res.next_batch); nhlog::net()->debug("sync completed: {}", res.next_batch);

Loading…
Cancel
Save