Save all state flags to ack_state_.

This commit is contained in:
levlam 2023-09-01 16:11:21 +03:00
parent 8b05c4f3ec
commit 5ce5ef6234
6 changed files with 11 additions and 9 deletions

View File

@ -153,7 +153,7 @@ class PingConnectionPingPong final
}
void on_message_failed(uint64 id, Status status) final {
}
void on_message_info(uint64 id, int32 state, uint64 answer_id, int32 answer_size) final {
void on_message_info(uint64 id, int32 state, uint64 answer_id, int32 answer_size, int32 source) final {
}
Status on_destroy_auth_key() final {

View File

@ -446,7 +446,7 @@ Status SessionConnection::on_msgs_state_info(const vector<int64> &message_ids, S
}
size_t i = 0;
for (auto message_id : message_ids) {
callback_->on_message_info(static_cast<uint64>(message_id), info[i], 0, 0);
callback_->on_message_info(static_cast<uint64>(message_id), info[i], 0, 0, 1);
i++;
}
return Status::OK();
@ -472,13 +472,13 @@ Status SessionConnection::on_packet(const MsgInfo &info, const mtproto_api::msgs
Status SessionConnection::on_packet(const MsgInfo &info, const mtproto_api::msg_detailed_info &msg_detailed_info) {
callback_->on_message_info(msg_detailed_info.msg_id_, msg_detailed_info.status_, msg_detailed_info.answer_msg_id_,
msg_detailed_info.bytes_);
msg_detailed_info.bytes_, 2);
return Status::OK();
}
Status SessionConnection::on_packet(const MsgInfo &info,
const mtproto_api::msg_new_detailed_info &msg_new_detailed_info) {
callback_->on_message_info(0, 0, msg_new_detailed_info.answer_msg_id_, msg_new_detailed_info.bytes_);
callback_->on_message_info(0, 0, msg_new_detailed_info.answer_msg_id_, msg_new_detailed_info.bytes_, 0);
return Status::OK();
}

View File

@ -119,7 +119,7 @@ class SessionConnection final
virtual Status on_message_result_ok(uint64 id, BufferSlice packet, size_t original_size) = 0;
virtual void on_message_result_error(uint64 id, int code, string message) = 0;
virtual void on_message_failed(uint64 id, Status status) = 0;
virtual void on_message_info(uint64 id, int32 state, uint64 answer_id, int32 answer_size) = 0;
virtual void on_message_info(uint64 id, int32 state, uint64 answer_id, int32 answer_size, int32 source) = 0;
virtual Status on_destroy_auth_key() = 0;
};

View File

@ -23,7 +23,7 @@ struct NetQueryDebug {
double state_timestamp_ = 0;
int32 state_change_count_ = 0;
int32 send_failed_count_ = 0;
int ack_state_ = 0;
int32 ack_state_ = 0;
bool unknown_state_ = false;
};

View File

@ -1046,7 +1046,8 @@ void Session::on_message_failed(uint64 message_id, Status status) {
on_message_failed_inner(message_id, false);
}
void Session::on_message_info(uint64 message_id, int32 state, uint64 answer_message_id, int32 answer_size) {
void Session::on_message_info(uint64 message_id, int32 state, uint64 answer_message_id, int32 answer_size,
int32 source) {
auto it = sent_queries_.find(message_id);
if (it != sent_queries_.end()) {
if (it->second.net_query_->update_is_ready()) {
@ -1079,7 +1080,8 @@ void Session::on_message_info(uint64 message_id, int32 state, uint64 answer_mess
}
// fallthrough
case 4:
on_message_ack_impl(message_id, answer_message_id == 0 ? 4 : 2);
CHECK(0 <= source && source <= 3);
on_message_ack_impl(message_id, (answer_message_id ? 2 : 0) | (((state | source) & ((1 << 28) - 1)) << 2));
break;
default:
LOG(ERROR) << "Invalid message info " << tag("state", state);

View File

@ -226,7 +226,7 @@ class Session final
void on_message_result_error(uint64 message_id, int error_code, string message) final;
void on_message_failed(uint64 message_id, Status status) final;
void on_message_info(uint64 message_id, int32 state, uint64 answer_message_id, int32 answer_size) final;
void on_message_info(uint64 message_id, int32 state, uint64 answer_message_id, int32 answer_size, int32 source) final;
Status on_destroy_auth_key() final;