address comments in code review

This commit is contained in:
Stephen Birarda 2015-08-28 09:47:25 -07:00
parent 21c80e45c2
commit dcd5a4aec2
3 changed files with 8 additions and 14 deletions

View file

@ -23,13 +23,12 @@ void FileResourceRequest::doSend() {
if (file.open(QFile::ReadOnly)) {
_data = file.readAll();
_result = ResourceRequest::Success;
emit finished();
} else {
_result = ResourceRequest::AccessDenied;
emit finished();
}
} else {
_result = ResourceRequest::NotFound;
emit finished();
}
emit finished();
}

View file

@ -304,14 +304,13 @@ void SendQueue::run() {
handshakeLock.unlock();
bool sentAPacket = maybeResendPacket();
bool flowWindowFull = false;
// if we didn't find a packet to re-send AND we think we can fit a new packet on the wire
// (this is according to the current flow window size) then we send out a new packet
if (_hasReceivedHandshakeACK && !sentAPacket) {
flowWindowFull = (seqlen(SequenceNumber { (uint32_t) _lastACKSequenceNumber }, _currentSequenceNumber) >
_flowWindowSize);
sentAPacket = maybeSendNewPacket();
if (seqlen(SequenceNumber { (uint32_t) _lastACKSequenceNumber }, _currentSequenceNumber) > _flowWindowSize) {
sentAPacket = maybeSendNewPacket();
}
}
// since we're a while loop, give the thread a chance to process events
@ -354,17 +353,17 @@ void SendQueue::run() {
if (uint32_t(_lastACKSequenceNumber) == uint32_t(_currentSequenceNumber)) {
// we've sent the client as much data as we have (and they've ACKed it)
// either wait for new data to send or 5 seconds before cleaning up the queue
static const auto EMPTY_QUEUES_INACTIVE_TIMEOUT_US = std::chrono::microseconds(5 * 1000 * 1000);
static const auto EMPTY_QUEUES_INACTIVE_TIMEOUT = std::chrono::seconds(5 * 1000 * 1000);
// use our condition_variable_any to wait
auto cvStatus = _emptyCondition.wait_for(doubleLock, EMPTY_QUEUES_INACTIVE_TIMEOUT_US);
auto cvStatus = _emptyCondition.wait_for(doubleLock, EMPTY_QUEUES_INACTIVE_TIMEOUT);
// we have the double lock again - Make sure to unlock it
doubleLock.unlock();
if (cvStatus == std::cv_status::timeout) {
qDebug() << "SendQueue to" << _destination << "has been empty for"
<< std::chrono::duration_cast<std::chrono::seconds>(EMPTY_QUEUES_INACTIVE_TIMEOUT_US).count()
<< EMPTY_QUEUES_INACTIVE_TIMEOUT.count()
<< "seconds and receiver has ACKed all packets."
<< "The queue is considered inactive and will be stopped.";

View file

@ -111,10 +111,6 @@ private:
std::atomic<int> _flowWindowSize { 0 }; // Flow control window size (number of packets that can be on wire) - set from CC
// Used to detect when the connection becomes inactive for too long
bool _flowWindowWasFull = false;
time_point _flowWindowFullSince;
mutable std::mutex _naksLock; // Protects the naks list.
LossList _naks; // Sequence numbers of packets to resend