More logging for bad messages (#907)

This commit is contained in:
Lonami Exo 2018-07-25 12:33:12 +02:00
parent b3990546eb
commit 7729a2a78f
2 changed files with 12 additions and 2 deletions

View File

@ -611,7 +611,7 @@ class MTProtoSender:
bad_msg = message.obj
msg = self._pending_messages.get(bad_msg.bad_msg_id)
__log__.debug('Handling bad msg for message %d', bad_msg.bad_msg_id)
__log__.debug('Handling bad msg %s', bad_msg)
if bad_msg.error_code in (16, 17):
# Sent msg_id too low or too high (respectively).
# Use the current msg_id to determine the right time offset.

View File

@ -157,10 +157,20 @@ class MTProtoState:
Updates the time offset to the correct
one given a known valid message ID.
"""
bad = self._get_new_msg_id()
old = self.time_offset
now = int(time.time())
correct = correct_msg_id >> 32
self.time_offset = correct - now
self._last_msg_id = 0
if self.time_offset != old:
self._last_msg_id = 0
__log__.debug(
'Updated time offset (old offset %d, bad %d, good %d, new %d)',
old, bad, correct_msg_id, self.time_offset
)
return self.time_offset
def _get_seq_no(self, content_related):