--- README-DNH.TXT.orig Wed Nov 9 21:18:31 2005 +++ README-DNH.TXT Sat Dec 10 11:06:38 2005 @@ -28,6 +28,29 @@ to use a different peer ID, but it is no longer necessary to do so in order to avoid this "ban". +Changes for "dnh1.2" Release + + These are just corrections to the previous release that I felt were + necessary. Much more improvement is coming in the dnh2 release. + + Bug/code fixes + * Bitfield::Invert patch [1357832 on sourceforge] described below. + * Fixed "piece length too long" check to reflect the actual queue + length used. + * Accept 128K slice size for peer requests. + * "Return" keyword in Random_init() removed due to potential compile + error. + * Modified longer-wait test in the optimistic unchoke routine to + consider whether the peer is currently choked. + +Bitfield::Invert bug + + There is a bug in the Bitfield::Invert() function that affects the + ctorrent-1.3.4 base code as well as releases dnh1 and dnh1.1. This can + cause the application to fail (segmentation fault) or may affect + downloading of all pieces of the torrent. A patch is available below + in the Download secion. + Changes for "dnh1.1" Release These are just corrections to the previous release that I felt were @@ -199,16 +222,44 @@ * Added -v (verbose) option for additional debugging output. Download + ___________________________________ + + Release dnh1.2 + + [12]dnh1.1 to dnh1.2 patch file + A patch file of changes to release dnh1.1 to bring it up to dnh1.2. + + [13]FreeBSD patch file + A patch file of changes to the CTorrent 1.3.4 base, including the + patches from the FreeBSD ports tree. + + [14]Patch file + A patch file of changes to the CTorrent 1.3.4 base. + + [15]FreeBSD patched source + This includes the patches from the FreeBSD ports tree. + + [16]Linux/Windows/Other patched source + Please [17]let me know if you encounter any portability issues, as I + don't have a test environment set up for these platforms. + ___________________________________ + + !!! Bitfield::Invert patch !!! + + [18]Bitfield::Invert patch + See notes above; this is needed if you are using dnh1.1, dnh1, or + ctorrent-1.3.4. + ___________________________________ Release dnh1.1 - [12]dnh1 to dnh1.1 patch file + [19]dnh1 to dnh1.1 patch file A patch file of changes to release dnh1 to bring it up to dnh1.1. ___________________________________ Release dnh1 - [13]FreeBSD patch file + [20]FreeBSD patch file A patch file of changes to the CTorrent 1.3.4 base, including the patches from the FreeBSD ports tree. Note: Thanks to Florent Thoumie, as of 29 Jul 2005 this patchset is @@ -216,61 +267,68 @@ least net/ctorrent) and install from there, you will have these updates without downloading the file and patching manually. - [14]Patch file + [21]Patch file A patch file of changes to the CTorrent 1.3.4 base. - [15]FreeBSD patched source + [22]FreeBSD patched source This includes the patches from the FreeBSD ports tree. - [16]Linux/Windows/Other patched source - Please [17]let me know if you encounter any portability issues, as I + [23]Linux/Windows/Other patched source + Please [24]let me know if you encounter any portability issues, as I don't have a test environment set up for these platforms. Resources - [18]CTorrent Home Page + [25]CTorrent Home Page Outdated, but you may find some useful info (particularly the FAQ). - [19]CTorrent SourceForge Project + [26]CTorrent SourceForge Project Hosts the CTorrent codebase, bug reports, patches, and forum. - [20]Custom CTorrent + [27]Custom CTorrent A page by the author of the "get1file" patch and other fixes. It contains a custom version and a GUI for CTorrent. - [21]BitTorrent + [28]BitTorrent The official BitTorrent home page. - [22]BitTorrent wiki + [29]BitTorrent wiki Various documentation. - [23]BitTorrent protocol specification (official version) + [30]BitTorrent protocol specification (official version) - [24]BitTorrent protocol specification (wiki version) + [31]BitTorrent protocol specification (wiki version) References - 1. http://www.rahul.net/dholmes/ctorrent/index.html#info - 2. http://www.rahul.net/dholmes/ctorrent/index.html#notes - 3. http://www.rahul.net/dholmes/ctorrent/index.html#changes - 4. http://www.rahul.net/dholmes/ctorrent/index.html#download - 5. http://www.rahul.net/dholmes/ctorrent/index.html#resources + 1. file://localhost/home/dholmes/public_html/ctorrent/index.html#info + 2. file://localhost/home/dholmes/public_html/ctorrent/index.html#notes + 3. file://localhost/home/dholmes/public_html/ctorrent/index.html#changes + 4. file://localhost/home/dholmes/public_html/ctorrent/index.html#download + 5. file://localhost/home/dholmes/public_html/ctorrent/index.html#resources 6. mailto:dholmes@ct.boxmail.com 7. http://ctorrent.sourceforge.net/ 8. http://www.bittorrent.com/ 9. http://sourceforge.net/projects/ctorrent/ 10. http://sourceforge.net/tracker/?atid=598034&group_id=91688&func=browse 11. http://groups.yahoo.com/group/BitTorrent/message/1260 - 12. http://www.rahul.net/dholmes/ctorrent/patchset-ctorrent-dnh1-dnh1.1.diff - 13. http://www.rahul.net/dholmes/ctorrent/patchset-ctorrent-1.3.4-dnh1-fbsd.diff - 14. http://www.rahul.net/dholmes/ctorrent/patchset-ctorrent-1.3.4-dnh1.diff - 15. http://www.rahul.net/dholmes/ctorrent/ctorrent-1.3.4-dnh1-fbsd.tar.gz - 16. http://www.rahul.net/dholmes/ctorrent/ctorrent-1.3.4-dnh1.tar.gz + 12. file://localhost/home/dholmes/public_html/ctorrent/patchset-ctorrent-dnh1.1-dnh1.2.diff + 13. file://localhost/home/dholmes/public_html/ctorrent/patchset-ctorrent-1.3.4-dnh1.2-fbsd.diff + 14. file://localhost/home/dholmes/public_html/ctorrent/patchset-ctorrent-1.3.4-dnh1.2.diff + 15. file://localhost/home/dholmes/public_html/ctorrent/ctorrent-1.3.4-dnh1.2-fbsd.tar.gz + 16. file://localhost/home/dholmes/public_html/ctorrent/ctorrent-1.3.4-dnh1.2.tar.gz 17. mailto:dholmes@ct.boxmail.com - 18. http://ctorrent.sourceforge.net/ - 19. http://sourceforge.net/projects/ctorrent/ - 20. http://customctorrent.ifreepages.com/ - 21. http://bittorrent.com/ - 22. http://wiki.theory.org/CategoryBitTorrent - 23. http://www.bittorrent.com/protocol.html - 24. http://wiki.theory.org/BitTorrentSpecification + 18. file://localhost/home/dholmes/public_html/ctorrent/patch-invert.diff + 19. file://localhost/home/dholmes/public_html/ctorrent/patchset-ctorrent-dnh1-dnh1.1.diff + 20. file://localhost/home/dholmes/public_html/ctorrent/patchset-ctorrent-1.3.4-dnh1-fbsd.diff + 21. file://localhost/home/dholmes/public_html/ctorrent/patchset-ctorrent-1.3.4-dnh1.diff + 22. file://localhost/home/dholmes/public_html/ctorrent/ctorrent-1.3.4-dnh1-fbsd.tar.gz + 23. file://localhost/home/dholmes/public_html/ctorrent/ctorrent-1.3.4-dnh1.tar.gz + 24. mailto:dholmes@ct.boxmail.com + 25. http://ctorrent.sourceforge.net/ + 26. http://sourceforge.net/projects/ctorrent/ + 27. http://customctorrent.ifreepages.com/ + 28. http://bittorrent.com/ + 29. http://wiki.theory.org/CategoryBitTorrent + 30. http://www.bittorrent.com/protocol.html + 31. http://wiki.theory.org/BitTorrentSpecification --- bitfield.cpp.orig Wed Sep 8 16:10:51 2004 +++ bitfield.cpp Thu Nov 17 20:34:00 2005 @@ -143,13 +143,25 @@ size_t s = nset; for( ; i < nbytes - 1; i++ ) b[i] = ~b[i]; - if( nbits % nbytes ){ - for( i = 8 * (nbytes - 1); i < nbits; i++ ) if( _isset(i) ) UnSet(i); else Set(i); +//dnh if( nbits % nbytes ){ +//consider nbits=10 (nbytes=2).... + if( nbits % 8 ){ + for( i = 8 * (nbytes - 1); i < nbits; i++ ) if( _isset(i) ) UnSet(i); else _set(i); }else b[nbytes - 1] = ~b[nbytes - 1]; nset = nbits - s; } +} + +// _set() sets the bit but doesn't increment nset or set the isfull case. +// Use instead of Set() when you know nset is incorrect and will be corrected +// afterward (as in Invert or by _recalc), +// and either bitfield won't get full or you'll _recalc() afterward to fix it. +void BitField::_set(size_t idx) +{ + if( idx < nbits && !_isfull() && !_isset(idx) ) + b[idx / 8] |= BIT_HEX[idx % 8]; } void BitField::Comb(const BitField &bf) --- bitfield.h.orig Wed Sep 8 16:10:51 2004 +++ bitfield.h Thu Nov 17 20:34:00 2005 @@ -14,6 +14,7 @@ inline void _recalc(); inline void _setall(unsigned char* buf); + inline void _set(size_t idx); public: BitField(); --- btconfig.h.orig Wed Nov 9 20:02:00 2005 +++ btconfig.h Tue Nov 22 12:35:47 2005 @@ -4,11 +4,15 @@ extern size_t cfg_req_slice_size; #define MAX_METAINFO_FILESIZ 4194304 +// According to specs the max slice size is 128K. But most clients do not +// accept a value that large, so we limit to 64K. Note that there is a +// comparison in RequestQueue::IsValidRequest() (see btrequest.cpp) that +// doubles the value so that we will accept a request for 128K. #define cfg_max_slice_size 65536 #define cfg_req_queue_length 64 #define MAX_PF_LEN 8 #define PEER_ID_LEN 20 -#define PEER_PFX "-CD0101-" +#define PEER_PFX "-CD0102-" extern size_t cfg_cache_size; --- btcontent.cpp.orig Wed Oct 26 20:51:00 2005 +++ btcontent.cpp Thu Nov 17 20:52:00 2005 @@ -215,8 +215,8 @@ if(!meta_int("info|piece length",&m_piece_length)) ERR_RETURN(); m_npieces = m_hashtable_length / 20; - if( m_piece_length > cfg_max_slice_size * cfg_req_queue_length ){ - fprintf(stderr,"error, piece length too long[%u]. please recompile CTorrent with a larger cfg_max_slice_size in .\n", m_piece_length); + if( m_piece_length > cfg_max_slice_size * (cfg_req_queue_length/2) ){ + fprintf(stderr,"error, piece length too long[%u]. please recompile CTorrent with a larger cfg_req_queue_length or cfg_max_slice_size in .\n", m_piece_length); ERR_RETURN(); } --- btrequest.cpp.orig Wed Nov 9 20:58:00 2005 +++ btrequest.cpp Sun Nov 20 17:07:18 2005 @@ -208,7 +208,8 @@ return ( idx < BTCONTENT.GetNPieces() && len && (off + len) <= BTCONTENT.GetPieceLength(idx) && - len <= cfg_max_slice_size) ? + // See note for cfg_max_slice_size in btconfig.h + len <= 2 * cfg_max_slice_size) ? 1 : 0; } --- ctorrent.cpp.orig Thu Jul 7 23:07:00 2005 +++ ctorrent.cpp Mon Nov 21 15:39:38 2005 @@ -46,7 +46,7 @@ struct timeval tv; gettimeofday(&tv,(struct timezone*) 0); unsigned int seed = tv.tv_usec + tv.tv_sec + getpid(); - return srandom(seed); + srandom(seed); } int main(int argc, char **argv) --- peerlist.cpp.orig Wed Oct 26 20:42:00 2005 +++ peerlist.cpp Sat Dec 10 10:31:47 2005 @@ -725,8 +725,18 @@ btPeer* tmp = peer_array[MAX_UNCHOKE]; peer_array[MAX_UNCHOKE] = loster; loster = tmp; - } else // if loser waited longer: - if(loster->GetLastUnchokeTime() < peer_array[MAX_UNCHOKE]->GetLastUnchokeTime()) { + } else + // This mess chooses the loser: + // if loser is choked and current is not + // OR if both are choked and loser has waited longer + // OR if both are unchoked and loser has had less time unchoked. + if( (!loster->Is_Local_UnChoked() && + ( peer_array[MAX_UNCHOKE]->Is_Local_UnChoked() || + loster->GetLastUnchokeTime() < + peer_array[MAX_UNCHOKE]->GetLastUnchokeTime() )) || + (peer_array[MAX_UNCHOKE]->Is_Local_UnChoked() && + peer_array[MAX_UNCHOKE]->GetLastUnchokeTime() < + loster->GetLastUnchokeTime()) ){ // if current is empty and loser is not, loser gets 25% chance; // else loser wins. // transformed to: if loser is empty or current isn't, or 25% chance,