From 1a8c9d941689af6dfbfa45c49f761428bd8d73c5 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 2 Sep 2012 20:41:25 +0000 Subject: [PATCH] patched fttransfermodule to always fulfill the data suze request, even if the file creator returns small (old pending) chunks, or stops at a chunk boundary. This should improve data flow and hep achievign hight speeds on fast internet connexions git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5505 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/ft/fttransfermodule.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/ft/fttransfermodule.cc b/libretroshare/src/ft/fttransfermodule.cc index a9c892eb4..002301c99 100644 --- a/libretroshare/src/ft/fttransfermodule.cc +++ b/libretroshare/src/ft/fttransfermodule.cc @@ -999,9 +999,12 @@ bool ftTransferModule::locked_tickPeerTransfer(peerInfo &info) uint64_t req_offset = 0; uint32_t req_size =0 ; - if (locked_getChunk(info.peerId,next_req,req_offset,req_size)) - { - if (req_size > 0) + // Loop over multiple calls to the file creator: for some reasons the file creator might not be able to + // give a plain chunk of the requested size (size hint larger than the fixed chunk size, priority given to + // an old pending chunk, etc). + // + while(next_req > 0 && locked_getChunk(info.peerId,next_req,req_offset,req_size)) + if(req_size > 0) { info.state = PQIPEER_DOWNLOADING; locked_requestData(info.peerId,req_offset,req_size); @@ -1013,13 +1016,14 @@ bool ftTransferModule::locked_tickPeerTransfer(peerInfo &info) info.rttActive = true; info.rttOffset = req_offset + req_size; } + next_req -= std::min(req_size,next_req) ; } else { std::cerr << "transfermodule::Waiting for available data"; std::cerr << std::endl; + break ; } - } return true; }