Ticket #2551: 0001-Prefetch-when-receiving-request.patch

File 0001-Prefetch-when-receiving-request.patch, 2.0 KB (added by jch, 11 years ago)
  • libtransmission/peer-msgs.c

    From f86fa4775517db9f09fcc47044ce033e75e40671 Mon Sep 17 00:00:00 2001
    From: Juliusz Chroboczek <jch@pps.jussieu.fr>
    Date: Mon, 9 Nov 2009 06:48:35 +0100
    Subject: [PATCH 1/3] Prefetch when receiving request.
     Forgotten by Charles.
    
    ---
     libtransmission/peer-msgs.c |   34 ++++++++++++++++++----------------
     1 files changed, 18 insertions(+), 16 deletions(-)
    
    diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c
    index e6fd889..c645587 100644
    a b updatePeerProgress( tr_peermsgs * msgs ) 
    12361236}
    12371237
    12381238static void
     1239prefetchPieces( tr_peermsgs *msgs )
     1240{
     1241    int i;
     1242
     1243    /* Maintain 12 prefetched blocks per unchoked peer */
     1244    for( i=msgs->prefetchCount; i<msgs->peerAskedForCount && i<12; ++i )
     1245    {
     1246        const struct peer_request * req = msgs->peerAskedFor + i;
     1247        tr_ioPrefetch( msgs->torrent, req->index, req->offset, req->length );
     1248        ++msgs->prefetchCount;
     1249    }
     1250}
     1251
     1252
     1253static void
    12391254peerMadeRequest( tr_peermsgs *               msgs,
    12401255                 const struct peer_request * req )
    12411256{
    peerMadeRequest( tr_peermsgs * msgs, 
    12571272    else
    12581273        allow = TRUE;
    12591274
    1260     if( allow )
     1275    if( allow ) {
    12611276        msgs->peerAskedFor[msgs->peerAskedForCount++] = *req;
    1262     else if( fext )
     1277        prefetchPieces( msgs );         
     1278    } else if( fext )
    12631279        protocolSendReject( msgs, req );
    12641280}
    12651281
    updateBlockRequests( tr_peermsgs * msgs ) 
    17981814    }
    17991815}
    18001816
    1801 static void
    1802 prefetchPieces( tr_peermsgs *msgs )
    1803 {
    1804     int i;
    1805 
    1806     /* Maintain 12 prefetched blocks per unchoked peer */
    1807     for( i=msgs->prefetchCount; i<msgs->peerAskedForCount && i<12; ++i )
    1808     {
    1809         const struct peer_request * req = msgs->peerAskedFor + i;
    1810         tr_ioPrefetch( msgs->torrent, req->index, req->offset, req->length );
    1811         ++msgs->prefetchCount;
    1812     }
    1813 }
    1814 
    18151817static size_t
    18161818fillOutputBuffer( tr_peermsgs * msgs, time_t now )
    18171819{