Skip to content

Commit

Permalink
WIP: fix possible rare error-code 32 problem (seq too low)
Browse files Browse the repository at this point in the history
Being hit by @Laiteux sometimes
  • Loading branch information
knocte committed Oct 14, 2020
1 parent 0dd6d70 commit d41fdab
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/TgSharp.Core/Network/MtProtoSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ public MtProtoSender(TcpTransport transport, ISessionStore sessionStore, Session
private int GenerateSequence(bool confirmed)
{
lock (session.Lock) {
var lastSequence = session.Sequence;
var newSequence = lastSequence + 1;
try {
return confirmed ? session.Sequence++ * 2 + 1 : session.Sequence * 2;
return confirmed ? newSequence * 2 + 1 : newSequence * 2;
} finally {
session.Sequence = newSequence;
sessionStore.Save(session);
}
}
Expand Down

0 comments on commit d41fdab

Please sign in to comment.