Skip to content

Commit

Permalink
Possibly fix wrong requests order.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed May 22, 2024
1 parent 5e3e9ba commit 84ec2a5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Telegram/SourceFiles/mtproto/mtp_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,11 +1020,24 @@ void Instance::Private::sendRequest(
const auto signedDcId = toMainDc ? -realShiftedDcId : realShiftedDcId;
registerRequest(requestId, signedDcId);

request->lastSentTime = crl::now();
request->needsLayer = needsLayer;

if (afterRequestId) {
request->after = getRequest(afterRequestId);

if (request->after) {
// Check if this after request is waiting in _dependentRequests.
// This happens if it was after some other request and failed
// to wait for it, but that other request is still processed.
QMutexLocker locker(&_dependentRequestsLock);
const auto i = _dependentRequests.find(afterRequestId);
if (i != end(_dependentRequests)) {
_dependentRequests.emplace(requestId, afterRequestId);
return;
}
}
}
request->lastSentTime = crl::now();
request->needsLayer = needsLayer;

session->sendPrepared(request, msCanWait);
}
Expand Down

0 comments on commit 84ec2a5

Please sign in to comment.