kopia lustrzana https://gitlab.com/eliggett/wfview
Try to fix lock condition in server
rodzic
db702123f9
commit
82b655cc09
|
@ -1573,56 +1573,53 @@ void udpServer::sendRetransmitRequest(CLIENT* c)
|
||||||
// We have at least 1 missing packet!
|
// We have at least 1 missing packet!
|
||||||
qDebug(logUdp()) << "Missing Seq: size=" << c->rxSeqBuf.size() << "firstKey=" << c->rxSeqBuf.firstKey() << "lastKey=" << c->rxSeqBuf.lastKey() << "missing=" << c->rxSeqBuf.lastKey() - c->rxSeqBuf.firstKey() - c->rxSeqBuf.size() + 1;
|
qDebug(logUdp()) << "Missing Seq: size=" << c->rxSeqBuf.size() << "firstKey=" << c->rxSeqBuf.firstKey() << "lastKey=" << c->rxSeqBuf.lastKey() << "missing=" << c->rxSeqBuf.lastKey() - c->rxSeqBuf.firstKey() - c->rxSeqBuf.size() + 1;
|
||||||
// We are missing packets so iterate through the buffer and add the missing ones to missing packet list
|
// We are missing packets so iterate through the buffer and add the missing ones to missing packet list
|
||||||
for (int i = 0; i < c->rxSeqBuf.keys().length() - 1; i++) {
|
if (c->rxMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||||
for (quint16 j = c->rxSeqBuf.keys()[i] + 1; j < c->rxSeqBuf.keys()[i + 1]; j++) {
|
{
|
||||||
auto s = c->rxMissing.find(j);
|
for (int i = 0; i < c->rxSeqBuf.keys().length() - 1; i++) {
|
||||||
if (s == c->rxMissing.end())
|
for (quint16 j = c->rxSeqBuf.keys()[i] + 1; j < c->rxSeqBuf.keys()[i + 1]; j++) {
|
||||||
{
|
auto s = c->rxMissing.find(j);
|
||||||
// We haven't seen this missing packet before
|
if (s == c->rxMissing.end())
|
||||||
qDebug(logUdp()) << this->metaObject()->className() << ": Adding to missing buffer (len=" << c->rxMissing.size() << "): " << j;
|
|
||||||
|
|
||||||
if (c->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
|
||||||
{
|
{
|
||||||
c->rxMissing.insert(j, 0);
|
// We haven't seen this missing packet before
|
||||||
c->missMutex.unlock();
|
qDebug(logUdp()) << this->metaObject()->className() << ": Adding to missing buffer (len=" << c->rxMissing.size() << "): " << j;
|
||||||
}
|
|
||||||
else {
|
|
||||||
qInfo(logUdpServer()) << "Unable to lock missMutex()";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (c->rxMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
|
||||||
{
|
|
||||||
if (c->rxSeqBuf.size() > 400)
|
|
||||||
{
|
|
||||||
c->rxSeqBuf.remove(0);
|
|
||||||
}
|
|
||||||
c->rxSeqBuf.insert(j, QTime::currentTime()); // Add this missing packet to the rxbuffer as we now long about it.
|
|
||||||
c->rxMutex.unlock();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qInfo(logUdpServer()) << "Unable to lock rxMutex()";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (s.value() == 4)
|
|
||||||
{
|
|
||||||
// We have tried 4 times to request this packet, time to give up!
|
|
||||||
if (c->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
if (c->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||||
{
|
{
|
||||||
s = c->rxMissing.erase(s);
|
c->rxMissing.insert(j, 0);
|
||||||
c->missMutex.unlock();
|
c->missMutex.unlock();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qInfo(logUdpServer()) << "Unable to lock missMutex()";
|
qInfo(logUdpServer()) << "Unable to lock missMutex()";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c->rxSeqBuf.size() > 400)
|
||||||
|
{
|
||||||
|
c->rxSeqBuf.remove(0);
|
||||||
|
c->rxSeqBuf.insert(j, QTime::currentTime()); // Add this missing packet to the rxbuffer as we now long about it.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (s.value() == 4)
|
||||||
|
{
|
||||||
|
// We have tried 4 times to request this packet, time to give up!
|
||||||
|
if (c->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||||
|
{
|
||||||
|
s = c->rxMissing.erase(s);
|
||||||
|
c->missMutex.unlock();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qInfo(logUdpServer()) << "Unable to lock missMutex()";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
c->rxMutex.unlock();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
qInfo(logUdpServer()) << "Unable to lock rxMutex()";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1667,9 +1664,10 @@ void udpServer::sendRetransmitRequest(CLIENT* c)
|
||||||
{
|
{
|
||||||
qDebug(logUdp()) << this->metaObject()->className() << ": sending request for multiple missing packets : " << missingSeqs.toHex();
|
qDebug(logUdp()) << this->metaObject()->className() << ": sending request for multiple missing packets : " << missingSeqs.toHex();
|
||||||
|
|
||||||
|
missingSeqs.insert(0, p.packet, sizeof(p.packet));
|
||||||
|
|
||||||
if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||||
{
|
{
|
||||||
missingSeqs.insert(0, p.packet, sizeof(p.packet));
|
|
||||||
c->socket->writeDatagram(missingSeqs, c->ipAddress, c->port);
|
c->socket->writeDatagram(missingSeqs, c->ipAddress, c->port);
|
||||||
udpMutex.unlock();
|
udpMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue