kopia lustrzana https://gitlab.com/eliggett/wfview
Mutex work in udpserver
rodzic
c7c4a326da
commit
36c778961e
|
@ -761,7 +761,8 @@ void udpServer::commonReceived(QList<CLIENT*>* l,CLIENT* current, QByteArray r)
|
|||
udpMutex.lock();
|
||||
current->socket->writeDatagram(match->data, current->ipAddress, current->port);
|
||||
udpMutex.unlock();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Just send an idle!
|
||||
sendControl(current, 0x00, in->seq);
|
||||
}
|
||||
|
@ -1182,7 +1183,7 @@ void udpServer::sendTokenResponse(CLIENT* c, quint8 type)
|
|||
|
||||
void udpServer::watchdog(CLIENT* c)
|
||||
{
|
||||
c->txMutex.lock();
|
||||
if (c->txMutex.tryLock()) {
|
||||
//qInfo(logUdpServer()) << c->ipAddress.toString() << ":" << c->port << ":Buffers tx:"<< c->txSeqBuf.length() << " rx:" << c->rxSeqBuf.length();
|
||||
// Erase old entries from the tx packet buffer. Keep the first 100 sent packets as we seem to get asked for these?
|
||||
if (!c->txSeqBuf.isEmpty())
|
||||
|
@ -1191,16 +1192,16 @@ void udpServer::watchdog(CLIENT* c)
|
|||
{ return v.timeSent.secsTo(QTime::currentTime()) > PURGE_SECONDS; }), c->txSeqBuf.end());
|
||||
}
|
||||
c->txMutex.unlock();
|
||||
|
||||
}
|
||||
// Erase old entries from the missing packets buffer
|
||||
c->missMutex.lock();
|
||||
if (c->missMutex.tryLock()) {
|
||||
if (!c->rxMissing.isEmpty()) {
|
||||
c->rxMissing.erase(std::remove_if(c->rxMissing.begin(), c->rxMissing.end(), [](const SEQBUFENTRY& v)
|
||||
{ return v.timeSent.secsTo(QTime::currentTime()) > PURGE_SECONDS; }), c->rxMissing.end());
|
||||
}
|
||||
c->missMutex.unlock();
|
||||
|
||||
c->rxMutex.lock();
|
||||
}
|
||||
if (c->rxMutex.tryLock()) {
|
||||
if (!c->rxSeqBuf.isEmpty()) {
|
||||
std::sort(c->rxSeqBuf.begin(), c->rxSeqBuf.end());
|
||||
|
||||
|
@ -1211,6 +1212,7 @@ void udpServer::watchdog(CLIENT* c)
|
|||
}
|
||||
c->rxMutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void udpServer::sendStatus(CLIENT* c)
|
||||
{
|
||||
|
@ -1339,10 +1341,13 @@ void udpServer::receiveAudioData(const audioPacket &d)
|
|||
client->txSeqBuf.last().data = t;
|
||||
client->txMutex.unlock();
|
||||
|
||||
udpMutex.lock();
|
||||
if (udpMutex.tryLock()) {
|
||||
client->socket->writeDatagram(t, client->ipAddress, client->port);
|
||||
udpMutex.unlock();
|
||||
|
||||
}
|
||||
else {
|
||||
qDebug(logUdpServer()) << "Failed to lock udpMutex()";
|
||||
}
|
||||
client->txSeq++;
|
||||
client->sendAudioSeq++;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue