diff --git a/udprecvqueue.h b/udprecvqueue.h index 2b98488..9d6cc68 100644 --- a/udprecvqueue.h +++ b/udprecvqueue.h @@ -38,6 +38,7 @@ public: bool canSentToTcp() const; int sendTcp(); void whenWriteToUdp(Time &t) const; + inline bool isConfirmRequired() const { return confirmRequired; } }; diff --git a/udpsendqueue.cpp b/udpsendqueue.cpp index bac1ab9..322879d 100644 --- a/udpsendqueue.cpp +++ b/udpsendqueue.cpp @@ -95,10 +95,7 @@ bool UdpSendQueue::sendUdpSingle() { if (e && timeLess(time, e->resendTime)) e = nullptr; - if (!e && !freeFirst) - return false; - - if (!e && !finalEntryAdded) { + if (!e && freeFirst && !finalEntryAdded) { int size = connection.tcpRecvQueue.busySize(); if (size > PACKET_SIZE) size = PACKET_SIZE; if (size < 0) size = 0; @@ -141,18 +138,36 @@ bool UdpSendQueue::sendUdpSingle() { int UdpSendQueue::sendUdp() { + Time time = connection.tunnel.time; + int sent = 0; while(sendUdpSingle()) { ++sent; if (sent == 100) { - if (timeLess(nextSendTime, connection.tunnel.time)) { + if (timeLess(nextSendTime, time)) { DebugMsg( "%u, time correction by %llu after sent %d packets", - connection.id.id, connection.tunnel.time - nextSendTime, sent ); - nextSendTime = connection.tunnel.time; + connection.id.id, time + 1 - nextSendTime, sent ); + nextSendTime = time + 1; } break; } } + + /* + while(timeLequal(nextSendTime, time) && connection.udpRecvQueue.isConfirmRequired()) { + if (sent == 100) { + DebugMsg( "%u, time correction by %llu after sent %d packets (extra confirmations)", + connection.id.id, time + 1 - nextSendTime, sent ); + nextSendTime = time + 1; + break; + } + DebugMsg("%u - nothing to send, send confirmation", connection.id.id); + connection.udpRecvQueue.sendUdpConfirm(true); + nextSendTime += connection.tunnel.udpSendDuration; + ++sent; + } + */ + return sent; } @@ -163,7 +178,7 @@ bool UdpSendQueue::canSentToUdp() const void UdpSendQueue::whenWriteToUdp(Time &t) const { int size = connection.tcpRecvQueue.busySize(); - if (busyFirst || size >= PACKET_SIZE) { + if (busyFirst || size >= PACKET_SIZE /*|| connection.udpRecvQueue.isConfirmRequired()*/) { if (timeLess(nextSendTime, t)) t = nextSendTime; } else if (size > 0) {