Show
Ignore:
Timestamp:
11/04/06 11:05:28 (6 years ago)
Author:
rakshasa
Message:

* Properly nul-terminate the info hash and client id in the tracker
request.

* Implemented options for read-ahead of
chunks. 'preload_min_pipelined', 'preload_min_size' and
'preload_required_rate' are used to decide when to read-ahead a chunk.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/libtorrent/src/protocol/peer_connection_base.cc

    r799 r800  
    4242#include "torrent/exceptions.h" 
    4343#include "torrent/block.h" 
     44#include "torrent/chunk_manager.h" 
    4445#include "data/chunk_iterator.h" 
    4546#include "data/chunk_list.h" 
     
    182183  } 
    183184 
    184   // Make sure we preload the next step once we get past the length 
    185   // here. This is just some testing, don't include this with the 
    186   // release. (Yet) 
    187 //   if (m_peerChunks.upload_throttle()->rate()->rate() >= 10 << 10) 
    188 //     m_upChunk.chunk()->preload(m_upPiece.offset(), m_upChunk.chunk()->size()); 
    189 //   m_upChunk.chunk()->preload(m_upPiece.offset(), std::min(128u << 10, m_peerChunks.upload_throttle()->rate()->rate() * 10)); 
     185  // Also check if we've already preloaded in the recent past, even 
     186  // past unmaps. 
     187  ChunkManager* cm = manager->chunk_manager(); 
     188 
     189  if (cm->preload_min_pipelined() == 0 || 
     190      m_upChunk.object()->time_preloaded() >= cachedTime - rak::timer::from_seconds(60)) 
     191    return; 
     192 
     193  uint32_t preloadSize = m_upPiece.offset() < cm->preload_min_size(); 
     194 
     195  if (preloadSize < cm->preload_min_size() || 
     196      m_peerChunks.upload_throttle()->rate()->rate() < cm->preload_required_rate() * (preloadSize + (2 << 20) - 1) / (2 << 20)) 
     197    return; 
     198 
     199  m_upChunk.chunk()->preload(m_upPiece.offset(), m_upChunk.chunk()->chunk_size()); 
    190200} 
    191201