2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Fix some possible crashes.

This commit is contained in:
John Preston
2018-06-04 22:48:17 +03:00
parent 31998406dd
commit a52392241d
4 changed files with 21 additions and 12 deletions

View File

@@ -1261,11 +1261,17 @@ void ConnectionPrivate::markConnectionOld() {
void ConnectionPrivate::sendPingByTimer() {
if (_pingId) {
if (_pingSendAt + kPingSendAfterForce - kPingSendAfter - TimeMs(1000) < getms(true)) {
// _pingSendAt: when to send next ping (lastPingAt + kPingSendAfter)
// could be equal to zero.
const auto now = getms(true);
const auto mustSendTill = _pingSendAt
+ kPingSendAfterForce
- kPingSendAfter;
if (mustSendTill < now + 1000) {
LOG(("Could not send ping for some seconds, restarting..."));
return restart();
} else {
_pingSender.callOnce(_pingSendAt + kPingSendAfterForce - kPingSendAfter - getms(true));
_pingSender.callOnce(mustSendTill - now);
}
} else {
emit needToSendAsync();