From c0ff0956eb11b8fa0a1200143aef0823e66bab5e Mon Sep 17 00:00:00 2001 From: Jesper Louis Andersen Date: Sat, 5 Jul 2008 02:13:34 +0200 Subject: [PATCH] When considering interest on a PieceSet handle chunked pieces correctly. --- TODO | 4 ++++ lib/etorrent-1.0/src/etorrent_chunk.erl | 1 + lib/etorrent-1.0/src/etorrent_piece.erl | 8 ++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 96510f9..e8b71c9 100644 --- a/TODO +++ b/TODO @@ -6,6 +6,10 @@ -- Keep the style please. Can be read with emacs org-mode ---------------------------------------------------------------------- +* pick_chunks to do the right thing with interest [Milestone: 0.9] + Currently, we do not take chunked pieces into account. And we + should! + * Implement graceful stopping of the etorrent application [Milestone: 1.0] The provisioning is there in OTP applications. We just need to leverage and use it. diff --git a/lib/etorrent-1.0/src/etorrent_chunk.erl b/lib/etorrent-1.0/src/etorrent_chunk.erl index 46dc94f..1c0da02 100644 --- a/lib/etorrent-1.0/src/etorrent_chunk.erl +++ b/lib/etorrent-1.0/src/etorrent_chunk.erl @@ -30,6 +30,7 @@ %% tags to return the needed data. %% %%-------------------------------------------------------------------- +%% TODO, not_interested here does not take chunked pieces into account! pick_chunks(Pid, Id, PieceSet, Remaining) -> case pick_chunks(pick_chunked, {Pid, Id, PieceSet, [], Remaining}) of not_interested -> diff --git a/lib/etorrent-1.0/src/etorrent_piece.erl b/lib/etorrent-1.0/src/etorrent_piece.erl index 666554c..2124184 100644 --- a/lib/etorrent-1.0/src/etorrent_piece.erl +++ b/lib/etorrent-1.0/src/etorrent_piece.erl @@ -143,7 +143,7 @@ bitfield(Id) when is_integer(Id) -> gb_sets:from_list(Fetched)). %%-------------------------------------------------------------------- -%% Function: check_interest(Id, PieceSet) -> interested | not_interested +%% Function: check_interest(Id, PieceSet) -> interested | not_interested | invalid_piece %% Description: Given a set of pieces, return if we are interested in any of them. %%-------------------------------------------------------------------- check_interest(Id, PieceSet) when is_integer(Id) -> @@ -158,10 +158,10 @@ find_interest_piece(Id, {Pn, Next}) -> invalid_piece; [P] when is_record(P, piece) -> case P#piece.state of - not_fetched -> - interested; + fetched -> + find_interest_piece(Id, gb_sets:next(Next)); _Other -> - find_interest_piece(Id, gb_sets:next(Next)) + interested end end. -- 2.11.4.GIT