[Libpdtp-svn] r60 - /
Status: Alpha
Brought to you by:
bascule
From: <tar...@pd...> - 2004-12-23 08:41:57
|
Author: tarcieri Date: 2004-12-23 01:42:38 -0700 (Thu, 23 Dec 2004) New Revision: 60 Modified: download.c Log: Download support updates Modified: download.c =================================================================== --- download.c 2004-12-23 08:26:54 UTC (rev 59) +++ download.c 2004-12-23 08:42:38 UTC (rev 60) @@ -593,6 +593,7 @@ static int download_piece_callback(pdtp_multiplexer_t mplx, pdtp_sock_t sock, const void *buffer, int bytes, void *arg) { piece_transfer_params_t params = (piece_transfer_params_t)arg; + uint32_t count; #ifndef NDEBUG debug("download_piece_callback invoked"); @@ -626,8 +627,14 @@ debug("Doing read_next_chunk"); #endif + /* Calculate bytes to read */ + count = params->bytes_total - params->bytes_transferred; + + if(count > TRANSFER_CHUNK_SIZE) + count = TRANSFER_CHUNK_SIZE; + /* XXX Add proper size calculation here */ - pdtp__async_read(mplx, sock, TRANSFER_CHUNK_SIZE, download_piece_callback, arg); + pdtp__async_read(mplx, sock, count, download_piece_callback, arg); return 1; err: |