mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
Fixed possible concurrency issue on msgId/seqno, that could freeze protocol or cause BadMsgNotification (during downloads for example)
Thanks goes to @Deeps00009
This commit is contained in:
parent
5358471574
commit
d49d620edd
|
|
@ -1430,8 +1430,11 @@ namespace WTelegram
|
|||
int seqno;
|
||||
long msgId = DateTime.UtcNow.Ticks + _dcSession.serverTicksOffset - 621355968000000000L;
|
||||
msgId = msgId * 428 + (msgId >> 24) * 25110956; // approximately unixtime*2^32 and divisible by 4
|
||||
lock (_session)
|
||||
{
|
||||
if (msgId <= _dcSession.lastSentMsgId) msgId = _dcSession.lastSentMsgId += 4; else _dcSession.lastSentMsgId = msgId;
|
||||
seqno = isContent ? _dcSession.seqno++ * 2 + 1 : _dcSession.seqno * 2;
|
||||
}
|
||||
return (msgId, seqno);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue