Drop session when we have to ignore a packet
GitOrigin-RevId: 2c6cc5bb4a022f0d7701cd8d7f8d3e4530191fc7
This commit is contained in:
parent
c2a873db4b
commit
591bfc542f
@ -23,7 +23,7 @@ Status MessageIdDuplicateChecker::check(int64 message_id) {
|
|||||||
if (saved_message_ids_.size() == MAX_SAVED_MESSAGE_IDS) {
|
if (saved_message_ids_.size() == MAX_SAVED_MESSAGE_IDS) {
|
||||||
auto oldest_message_id = *saved_message_ids_.begin();
|
auto oldest_message_id = *saved_message_ids_.begin();
|
||||||
if (message_id < oldest_message_id) {
|
if (message_id < oldest_message_id) {
|
||||||
return Status::Error(1, PSLICE() << "Ignore very old message_id " << tag("oldest message_id", oldest_message_id)
|
return Status::Error(2, PSLICE() << "Ignore very old message_id " << tag("oldest message_id", oldest_message_id)
|
||||||
<< tag("got message_id", message_id));
|
<< tag("got message_id", message_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -488,6 +488,11 @@ Status SessionConnection::on_slice_packet(const MsgInfo &info, Slice packet) {
|
|||||||
// It is an update... I hope.
|
// It is an update... I hope.
|
||||||
auto status = auth_data_->check_update(info.message_id);
|
auto status = auth_data_->check_update(info.message_id);
|
||||||
if (status.is_error()) {
|
if (status.is_error()) {
|
||||||
|
if (status.code() == 2) {
|
||||||
|
LOG(WARNING) << "Receive too old update: " << status;
|
||||||
|
callback_->on_session_failed(Status::Error("Receive too old update"));
|
||||||
|
return status;
|
||||||
|
}
|
||||||
VLOG(mtproto) << "Skip update " << info.message_id << " from " << get_name() << " created in "
|
VLOG(mtproto) << "Skip update " << info.message_id << " from " << get_name() << " created in "
|
||||||
<< (Time::now() - created_at_) << ": " << status;
|
<< (Time::now() - created_at_) << ": " << status;
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
@ -666,6 +671,10 @@ Status SessionConnection::on_raw_packet(const td::mtproto::PacketInfo &info, Buf
|
|||||||
LOG(WARNING) << "Packet ignored " << status;
|
LOG(WARNING) << "Packet ignored " << status;
|
||||||
send_ack(info.message_id);
|
send_ack(info.message_id);
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
|
} else if (status.code() == 2) {
|
||||||
|
LOG(WARNING) << "Receive too old packet: " << status;
|
||||||
|
callback_->on_session_failed(Status::Error("Receive too old packet"));
|
||||||
|
return status;
|
||||||
} else {
|
} else {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user