Return after call to on_error.
This commit is contained in:
parent
d912fd1431
commit
1588f0d687
@ -263,11 +263,14 @@ class TlsHelloCalcLength {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<size_t> finish() {
|
Result<size_t> finish() {
|
||||||
|
if (status_.is_error()) {
|
||||||
|
return std::move(status_);
|
||||||
|
}
|
||||||
if (size_ > 514) {
|
if (size_ > 514) {
|
||||||
on_error(Status::Error("Too long for zero padding"));
|
return Status::Error("Too long for zero padding");
|
||||||
}
|
}
|
||||||
if (size_ < 11 + 32) {
|
if (size_ < 11 + 32) {
|
||||||
on_error(Status::Error("Too small for hash"));
|
return Status::Error("Too small for hash");
|
||||||
}
|
}
|
||||||
int zero_pad = 515 - static_cast<int>(size_);
|
int zero_pad = 515 - static_cast<int>(size_);
|
||||||
using Op = TlsHello::Op;
|
using Op = TlsHello::Op;
|
||||||
@ -275,9 +278,8 @@ class TlsHelloCalcLength {
|
|||||||
do_op(Op::zero(zero_pad), nullptr);
|
do_op(Op::zero(zero_pad), nullptr);
|
||||||
do_op(Op::end_scope(), nullptr);
|
do_op(Op::end_scope(), nullptr);
|
||||||
if (!scope_offset_.empty()) {
|
if (!scope_offset_.empty()) {
|
||||||
on_error(Status::Error("Unbalanced scopes"));
|
return Status::Error("Unbalanced scopes");
|
||||||
}
|
}
|
||||||
TRY_STATUS(std::move(status_));
|
|
||||||
return size_;
|
return size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1684,7 +1684,7 @@ class SaveDraftMessageQuery final : public Td::ResultHandler {
|
|||||||
|
|
||||||
bool result = result_ptr.ok();
|
bool result = result_ptr.ok();
|
||||||
if (!result) {
|
if (!result) {
|
||||||
on_error(Status::Error(400, "Save draft failed"));
|
return on_error(Status::Error(400, "Save draft failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
promise_.set_value(Unit());
|
promise_.set_value(Unit());
|
||||||
@ -1761,7 +1761,7 @@ class ToggleDialogPinQuery final : public Td::ResultHandler {
|
|||||||
|
|
||||||
bool result = result_ptr.ok();
|
bool result = result_ptr.ok();
|
||||||
if (!result) {
|
if (!result) {
|
||||||
on_error(Status::Error(400, "Toggle dialog pin failed"));
|
return on_error(Status::Error(400, "Toggle dialog pin failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
promise_.set_value(Unit());
|
promise_.set_value(Unit());
|
||||||
@ -1849,7 +1849,7 @@ class ToggleDialogUnreadMarkQuery final : public Td::ResultHandler {
|
|||||||
|
|
||||||
bool result = result_ptr.ok();
|
bool result = result_ptr.ok();
|
||||||
if (!result) {
|
if (!result) {
|
||||||
on_error(Status::Error(400, "Toggle dialog mark failed"));
|
return on_error(Status::Error(400, "Toggle dialog mark failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
promise_.set_value(Unit());
|
promise_.set_value(Unit());
|
||||||
|
@ -199,10 +199,10 @@ class CanPurchasePremiumQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool result = result_ptr.ok();
|
bool result = result_ptr.ok();
|
||||||
if (result) {
|
if (!result) {
|
||||||
return promise_.set_value(Unit());
|
return on_error(Status::Error(400, "Premium can't be purchased"));
|
||||||
}
|
}
|
||||||
on_error(Status::Error(400, "Premium can't be purchased"));
|
promise_.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_error(Status status) final {
|
void on_error(Status status) final {
|
||||||
|
@ -864,11 +864,10 @@ class ReloadSpecialStickerSetQuery final : public Td::ResultHandler {
|
|||||||
td_->stickers_manager_->on_get_messages_sticker_set(sticker_set_id_, std::move(set_ptr), false,
|
td_->stickers_manager_->on_get_messages_sticker_set(sticker_set_id_, std::move(set_ptr), false,
|
||||||
"ReloadSpecialStickerSetQuery");
|
"ReloadSpecialStickerSetQuery");
|
||||||
}
|
}
|
||||||
if (sticker_set_id_.is_valid()) {
|
if (!sticker_set_id_.is_valid()) {
|
||||||
td_->stickers_manager_->on_get_special_sticker_set(type_, sticker_set_id_);
|
return on_error(Status::Error(500, "Failed to add special sticker set"));
|
||||||
} else {
|
|
||||||
on_error(Status::Error(500, "Failed to add special sticker set"));
|
|
||||||
}
|
}
|
||||||
|
td_->stickers_manager_->on_get_special_sticker_set(type_, sticker_set_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_error(Status status) final {
|
void on_error(Status status) final {
|
||||||
|
@ -2446,8 +2446,7 @@ void FileManager::run_download(FileNodePtr node, bool force_update_priority) {
|
|||||||
QueryId query_id = queries_container_.create(Query{file_id, Query::Type::DownloadWaitFileReference});
|
QueryId query_id = queries_container_.create(Query{file_id, Query::Type::DownloadWaitFileReference});
|
||||||
node->download_id_ = query_id;
|
node->download_id_ = query_id;
|
||||||
if (node->download_was_update_file_reference_) {
|
if (node->download_was_update_file_reference_) {
|
||||||
on_error(query_id, Status::Error("Can't download file: have no valid file reference"));
|
return on_error(query_id, Status::Error("Can't download file: have no valid file reference"));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
node->download_was_update_file_reference_ = true;
|
node->download_was_update_file_reference_ = true;
|
||||||
|
|
||||||
@ -2951,8 +2950,7 @@ void FileManager::run_upload(FileNodePtr node, vector<int> bad_parts) {
|
|||||||
QueryId query_id = queries_container_.create(Query{file_id, Query::Type::UploadWaitFileReference});
|
QueryId query_id = queries_container_.create(Query{file_id, Query::Type::UploadWaitFileReference});
|
||||||
node->upload_id_ = query_id;
|
node->upload_id_ = query_id;
|
||||||
if (node->upload_was_update_file_reference_) {
|
if (node->upload_was_update_file_reference_) {
|
||||||
on_error(query_id, Status::Error("Can't upload file: have no valid file reference"));
|
return on_error(query_id, Status::Error("Can't upload file: have no valid file reference"));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
node->upload_was_update_file_reference_ = true;
|
node->upload_was_update_file_reference_ = true;
|
||||||
|
|
||||||
|
@ -67,14 +67,14 @@ void TransparentProxy::loop() {
|
|||||||
TRY_STATUS(fd_.flush_read());
|
TRY_STATUS(fd_.flush_read());
|
||||||
TRY_STATUS(loop_impl());
|
TRY_STATUS(loop_impl());
|
||||||
TRY_STATUS(fd_.flush_write());
|
TRY_STATUS(fd_.flush_write());
|
||||||
|
if (can_close_local(fd_)) {
|
||||||
|
return Status::Error("Connection closed");
|
||||||
|
}
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}();
|
}();
|
||||||
if (status.is_error()) {
|
if (status.is_error()) {
|
||||||
on_error(std::move(status));
|
on_error(std::move(status));
|
||||||
}
|
}
|
||||||
if (can_close_local(fd_)) {
|
|
||||||
on_error(Status::Error("Connection closed"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransparentProxy::timeout_expired() {
|
void TransparentProxy::timeout_expired() {
|
||||||
|
@ -35,7 +35,7 @@ class StringBuilder {
|
|||||||
void push_back(char c) {
|
void push_back(char c) {
|
||||||
if (unlikely(end_ptr_ <= current_ptr_)) {
|
if (unlikely(end_ptr_ <= current_ptr_)) {
|
||||||
if (!reserve_inner(RESERVED_SIZE)) {
|
if (!reserve_inner(RESERVED_SIZE)) {
|
||||||
on_error();
|
error_flag_ = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user