mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-23 22:12:43 +00:00
fixed deadlock
This commit is contained in:
parent
02f4835e31
commit
cc0cf35725
@ -3357,33 +3357,39 @@ void VoIPController::UpdateSignalBars(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VoIPController::UpdateQueuedPackets(){
|
void VoIPController::UpdateQueuedPackets(){
|
||||||
MutexGuard m(queuedPacketsMutex);
|
vector<PendingOutgoingPacket> packetsToSend;
|
||||||
for(std::vector<QueuedPacket>::iterator qp=queuedPackets.begin();qp!=queuedPackets.end();){
|
{
|
||||||
if(qp->timeout>0 && qp->firstSentTime>0 && GetCurrentTime()-qp->firstSentTime>=qp->timeout){
|
MutexGuard m(queuedPacketsMutex);
|
||||||
LOGD("Removing queued packet because of timeout");
|
for(std::vector<QueuedPacket>::iterator qp=queuedPackets.begin(); qp!=queuedPackets.end();){
|
||||||
qp=queuedPackets.erase(qp);
|
if(qp->timeout>0 && qp->firstSentTime>0 && GetCurrentTime()-qp->firstSentTime>=qp->timeout){
|
||||||
continue;
|
LOGD("Removing queued packet because of timeout");
|
||||||
|
qp=queuedPackets.erase(qp);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(GetCurrentTime()-qp->lastSentTime>=qp->retryInterval){
|
||||||
|
messageThread.Post(std::bind(&VoIPController::UpdateQueuedPackets, this), qp->retryInterval);
|
||||||
|
uint32_t seq=GenerateOutSeq();
|
||||||
|
qp->seqs.Add(seq);
|
||||||
|
qp->lastSentTime=GetCurrentTime();
|
||||||
|
//LOGD("Sending queued packet, seq=%u, type=%u, len=%u", seq, qp.type, qp.data.Length());
|
||||||
|
Buffer buf(qp->data.Length());
|
||||||
|
if(qp->firstSentTime==0)
|
||||||
|
qp->firstSentTime=qp->lastSentTime;
|
||||||
|
if(qp->data.Length())
|
||||||
|
buf.CopyFrom(qp->data, qp->data.Length());
|
||||||
|
packetsToSend.push_back(PendingOutgoingPacket{
|
||||||
|
/*.seq=*/seq,
|
||||||
|
/*.type=*/qp->type,
|
||||||
|
/*.len=*/qp->data.Length(),
|
||||||
|
/*.data=*/move(buf),
|
||||||
|
/*.endpoint=*/0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
++qp;
|
||||||
}
|
}
|
||||||
if(GetCurrentTime()-qp->lastSentTime>=qp->retryInterval){
|
}
|
||||||
messageThread.Post(std::bind(&VoIPController::UpdateQueuedPackets, this), qp->retryInterval);
|
for(PendingOutgoingPacket& pkt:packetsToSend){
|
||||||
uint32_t seq=GenerateOutSeq();
|
SendOrEnqueuePacket(move(pkt));
|
||||||
qp->seqs.Add(seq);
|
|
||||||
qp->lastSentTime=GetCurrentTime();
|
|
||||||
//LOGD("Sending queued packet, seq=%u, type=%u, len=%u", seq, qp.type, qp.data.Length());
|
|
||||||
Buffer buf(qp->data.Length());
|
|
||||||
if(qp->firstSentTime==0)
|
|
||||||
qp->firstSentTime=qp->lastSentTime;
|
|
||||||
if(qp->data.Length())
|
|
||||||
buf.CopyFrom(qp->data, qp->data.Length());
|
|
||||||
SendOrEnqueuePacket(PendingOutgoingPacket{
|
|
||||||
/*.seq=*/seq,
|
|
||||||
/*.type=*/qp->type,
|
|
||||||
/*.len=*/qp->data.Length(),
|
|
||||||
/*.data=*/move(buf),
|
|
||||||
/*.endpoint=*/0
|
|
||||||
});
|
|
||||||
}
|
|
||||||
++qp;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user