Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 112352 | Differences between
and this patch

Collapse All | Expand All

(-)README-DNH.TXT.orig (-31 / +75 lines)
Lines 1-5 Link Here
1
Please see http://www.rahul.net/dholmes/ctorrent/ for the latest version
2
of this information.
3
1
4
                             Enhanced CTorrent
2
                             Enhanced CTorrent
5
3
Lines 23-37 Link Here
23
21
24
Notes
22
Notes
25
23
26
   Use of the -P option (or changing the peer ID in btconfig.h) is
24
   Beginning with dnh1.1 the default peer ID has been changed for
27
   recommended, as some other clients and trackers assume that Ctorrent
25
   convenience, as some other clients and trackers assume that Ctorrent
28
   is "buggy" and won't cooperate with it. [Guess what, there are plenty
26
   is "buggy" and won't cooperate with it. [Guess what, there are plenty
29
   of others with bugs too.] It isn't necessary to impersonate another
27
   of others with bugs too.] The -P option is still available if you wish
30
   known client; just changing or adding one letter or number should be
28
   to use a different peer ID, but it is no longer necessary to do so in
31
   sufficient.
29
   order to avoid this "ban".
30
31
Changes for "dnh1.1" Release
32
33
   These are just corrections to the previous release that I felt were
34
   necessary. Much more improvement is coming in the next release.
35
36
   Bug/code fixes
37
     * Peer count would increase on each tracker update if there were no
38
       seeders.
39
     * RequestQueue::CopyShuffle() changed to use a pointer argument.
40
     * Fixed some incorrectness in PendingQueue::Delete() and
41
       PendingQueue::DeleteSlice() which could cause a memory leak.
42
     * Fixed random-chance inversion bug in PeerList::UnChokeCheck()
43
       affecting choice for optimistic unchoking.
44
45
   Improvements
46
     * Move StopDLTimer() call from RequestPiece() to RequestCheck(),
47
       which could occasionally affect peer download rate measurement.
48
     * Most clients do not like a slice size of 128K even though it is
49
       the max allowed by the BT specification. Changed max slice size to
50
       64K. Note that the maximum piece length is 2MB (2097152); if you
51
       need to download a torrent with a larger piece size you can change
52
       the value of cfg_req_queue_length in btconfig.h from 64 to 128.
53
     * Contact tracker immediately upon becoming (or starting as) a
54
       seeder.
55
     * Changed SendModule() to send only one slice at a time. This will
56
       help with fairly distributing upload bandwidth among the unchoked
57
       peers.
58
     * Changed default peer ID prefix to '-CD0101-', indicating
59
       CTorrent-dnh1.1 release.
32
60
33
Changes for "dnh1" Release
61
Changes for "dnh1" Release
34
62
63
   This is the first release. "dnh" identifies this patchset, and "1"
64
   indicates release version 1 of the patchset.
65
35
   Patches
66
   Patches
36
     * Incorporates the following patches. The number is the Request ID
67
     * Incorporates the following patches. The number is the Request ID
37
       from the [10]SourceForge patches page, which you can reference for
68
       from the [10]SourceForge patches page, which you can reference for
Lines 169-209 Link Here
169
200
170
Download
201
Download
171
202
172
   [12]FreeBSD patch file
203
   Release dnh1.1
204
205
   [12]dnh1 to dnh1.1 patch file
206
   A patch file of changes to release dnh1 to bring it up to dnh1.1.
207
                    ___________________________________
208
209
   Release dnh1
210
211
   [13]FreeBSD patch file
173
   A patch file of changes to the CTorrent 1.3.4 base, including the
212
   A patch file of changes to the CTorrent 1.3.4 base, including the
174
   patches from the FreeBSD ports tree.
213
   patches from the FreeBSD ports tree.
214
   Note: Thanks to Florent Thoumie, as of 29 Jul 2005 this patchset is
215
   included in the FreeBSD port. If you update your ports tree (or at
216
   least net/ctorrent) and install from there, you will have these
217
   updates without downloading the file and patching manually.
175
218
176
   [13]Patch file
219
   [14]Patch file
177
   A patch file of changes to the CTorrent 1.3.4 base.
220
   A patch file of changes to the CTorrent 1.3.4 base.
178
221
179
   [14]FreeBSD patched source
222
   [15]FreeBSD patched source
180
   This includes the patches from the FreeBSD ports tree.
223
   This includes the patches from the FreeBSD ports tree.
181
224
182
   [15]Linux/Windows/Other patched source
225
   [16]Linux/Windows/Other patched source
183
   Please [16]let me know if you encounter any portability issues, as I
226
   Please [17]let me know if you encounter any portability issues, as I
184
   don't have a test environment set up for these platforms.
227
   don't have a test environment set up for these platforms.
185
228
186
Resources
229
Resources
187
230
188
   [17]CTorrent Home Page 
231
   [18]CTorrent Home Page 
189
   Outdated, but you may find some useful info (particularly the FAQ).
232
   Outdated, but you may find some useful info (particularly the FAQ).
190
233
191
   [18]CTorrent SourceForge Project 
234
   [19]CTorrent SourceForge Project 
192
   Hosts the CTorrent codebase, bug reports, patches, and forum.
235
   Hosts the CTorrent codebase, bug reports, patches, and forum.
193
236
194
   [19]Custom CTorrent 
237
   [20]Custom CTorrent 
195
   A page by the author of the "get1file" patch and other fixes. It
238
   A page by the author of the "get1file" patch and other fixes. It
196
   contains a custom version and a GUI for CTorrent.
239
   contains a custom version and a GUI for CTorrent.
197
240
198
   [20]BitTorrent 
241
   [21]BitTorrent 
199
   The official BitTorrent home page.
242
   The official BitTorrent home page.
200
243
201
   [21]BitTorrent wiki 
244
   [22]BitTorrent wiki 
202
   Various documentation.
245
   Various documentation.
203
246
204
   [22]BitTorrent protocol specification (official version)
247
   [23]BitTorrent protocol specification (official version)
205
248
206
   [23]BitTorrent protocol specification (wiki version)
249
   [24]BitTorrent protocol specification (wiki version)
207
250
208
References
251
References
209
252
Lines 218-232 Link Here
218
   9. http://sourceforge.net/projects/ctorrent/
261
   9. http://sourceforge.net/projects/ctorrent/
219
  10. http://sourceforge.net/tracker/?atid=598034&group_id=91688&func=browse
262
  10. http://sourceforge.net/tracker/?atid=598034&group_id=91688&func=browse
220
  11. http://groups.yahoo.com/group/BitTorrent/message/1260
263
  11. http://groups.yahoo.com/group/BitTorrent/message/1260
221
  12. http://www.rahul.net/dholmes/ctorrent/ctorrent-dnh1-fbsd.diff
264
  12. http://www.rahul.net/dholmes/ctorrent/patchset-ctorrent-dnh1-dnh1.1.diff
222
  13. http://www.rahul.net/dholmes/ctorrent/ctorrent-dnh1.diff
265
  13. http://www.rahul.net/dholmes/ctorrent/patchset-ctorrent-1.3.4-dnh1-fbsd.diff
223
  14. http://www.rahul.net/dholmes/ctorrent/ctorrent-dnh1-fbsd.tar.gz
266
  14. http://www.rahul.net/dholmes/ctorrent/patchset-ctorrent-1.3.4-dnh1.diff
224
  15. http://www.rahul.net/dholmes/ctorrent/ctorrent-dnh1.tar.gz
267
  15. http://www.rahul.net/dholmes/ctorrent/ctorrent-1.3.4-dnh1-fbsd.tar.gz
225
  16. mailto:dholmes@ct.boxmail.com
268
  16. http://www.rahul.net/dholmes/ctorrent/ctorrent-1.3.4-dnh1.tar.gz
226
  17. http://ctorrent.sourceforge.net/
269
  17. mailto:dholmes@ct.boxmail.com
227
  18. http://sourceforge.net/projects/ctorrent/
270
  18. http://ctorrent.sourceforge.net/
228
  19. http://customctorrent.ifreepages.com/
271
  19. http://sourceforge.net/projects/ctorrent/
229
  20. http://bittorrent.com/
272
  20. http://customctorrent.ifreepages.com/
230
  21. http://wiki.theory.org/CategoryBitTorrent
273
  21. http://bittorrent.com/
231
  22. http://www.bittorrent.com/protocol.html
274
  22. http://wiki.theory.org/CategoryBitTorrent
232
  23. http://wiki.theory.org/BitTorrentSpecification
275
  23. http://www.bittorrent.com/protocol.html
276
  24. http://wiki.theory.org/BitTorrentSpecification
(-)btconfig.h.dnh1 (-2 / +2 lines)
Lines 4-14 Link Here
4
extern size_t cfg_req_slice_size;
4
extern size_t cfg_req_slice_size;
5
5
6
#define MAX_METAINFO_FILESIZ	4194304
6
#define MAX_METAINFO_FILESIZ	4194304
7
#define cfg_max_slice_size 131072
7
#define cfg_max_slice_size 65536
8
#define cfg_req_queue_length 64
8
#define cfg_req_queue_length 64
9
#define MAX_PF_LEN 8
9
#define MAX_PF_LEN 8
10
#define PEER_ID_LEN 20
10
#define PEER_ID_LEN 20
11
#define PEER_PFX "-CT1304-"
11
#define PEER_PFX "-CD0101-"
12
12
13
extern size_t cfg_cache_size;
13
extern size_t cfg_cache_size;
14
14
(-)btcontent.cpp.dnh1 (-1 / +1 lines)
Lines 614-620 Link Here
614
{
614
{
615
  if( pBF->IsFull() ){
615
  if( pBF->IsFull() ){
616
    if( !m_seed_timestamp ){
616
    if( !m_seed_timestamp ){
617
      Tracker.Reset(15);
617
      Tracker.Reset(1);
618
      Self.ResetDLTimer();
618
      Self.ResetDLTimer();
619
      Self.ResetULTimer();
619
      Self.ResetULTimer();
620
      ReleaseHashTable();
620
      ReleaseHashTable();
(-)btrequest.cpp.dnh1 (-5 / +6 lines)
Lines 44-57 Link Here
44
  rq.rq_head = (PSLICE) 0;
44
  rq.rq_head = (PSLICE) 0;
45
}
45
}
46
46
47
int RequestQueue::CopyShuffle(RequestQueue &rq)
47
int RequestQueue::CopyShuffle(RequestQueue *prq)
48
{
48
{
49
  PSLICE ps;
49
  PSLICE ps;
50
50
51
  if( rq_head ) _empty_slice_list(&rq_head);
51
  if( rq_head ) _empty_slice_list(&rq_head);
52
  
52
  
53
  if( rq.IsEmpty() ) return 0;
53
  if( prq->IsEmpty() ) return 0;
54
  for (ps = rq.GetHead(); ps; ps = ps->next) {
54
  for (ps = prq->GetHead(); ps; ps = ps->next) {
55
    if (random()&01) {
55
    if (random()&01) {
56
      if (Add(ps->index, ps->offset, ps->length) < 0) return -1;
56
      if (Add(ps->index, ps->offset, ps->length) < 0) return -1;
57
    }
57
    }
Lines 289-296 Link Here
289
   int i = 0;
289
   int i = 0;
290
  for ( ; i < PENDING_QUEUE_SIZE && pq_count; i++){
290
  for ( ; i < PENDING_QUEUE_SIZE && pq_count; i++){
291
    if( (PSLICE) 0 != pending_array[i] && idx == pending_array[i]->index){
291
    if( (PSLICE) 0 != pending_array[i] && idx == pending_array[i]->index){
292
      delete pending_array[i];
292
      _empty_slice_list(&(pending_array[i]));
293
      pending_array[i] = (PSLICE) 0;
293
      pq_count--;
294
    }
294
    }
295
  }
295
  }
296
  return 0;
296
  return 0;
Lines 308-313 Link Here
308
      if( rq.Remove(idx, off, len) == 0 )
308
      if( rq.Remove(idx, off, len) == 0 )
309
        pending_array[i] = rq.GetHead();
309
        pending_array[i] = rq.GetHead();
310
      rq.Release();
310
      rq.Release();
311
      if( (PSLICE) 0 == pending_array[i] ) pq_count--;
311
    }
312
    }
312
  }
313
  }
313
  return 0;
314
  return 0;
(-)btrequest.h.dnh1 (-1 / +1 lines)
Lines 31-37 Link Here
31
  int IsValidRequest(size_t idx,size_t off,size_t len);
31
  int IsValidRequest(size_t idx,size_t off,size_t len);
32
32
33
  void operator=(RequestQueue &rq);
33
  void operator=(RequestQueue &rq);
34
  int CopyShuffle(RequestQueue &rq);
34
  int CopyShuffle(RequestQueue *prq);
35
  size_t Qsize();
35
  size_t Qsize();
36
36
37
  int IsEmpty() const { return rq_head ? 0 : 1; }
37
  int IsEmpty() const { return rq_head ? 0 : 1; }
(-)peer.cpp.dnh1 (-4 / +4 lines)
Lines 156-162 Link Here
156
    if(peer){
156
    if(peer){
157
      if(arg_verbose) fprintf( stderr, "Duping: %p to %p (#%u)\n",
157
      if(arg_verbose) fprintf( stderr, "Duping: %p to %p (#%u)\n",
158
        peer, this, peer->request_q.GetRequestIdx() );
158
        peer, this, peer->request_q.GetRequestIdx() );
159
      return (request_q.CopyShuffle(peer->request_q) < 0) ? -1 : SendRequest();
159
      return (request_q.CopyShuffle(&peer->request_q) < 0) ? -1 : SendRequest();
160
    }
160
    }
161
  }	// Doesn't have a piece that's already in progress--choose another.
161
  }	// Doesn't have a piece that's already in progress--choose another.
162
    BitField tmpBitField;
162
    BitField tmpBitField;
Lines 186-192 Link Here
186
	  btPeer *peer = WORLD.Who_Can_Duplicate(this, idx);
186
	  btPeer *peer = WORLD.Who_Can_Duplicate(this, idx);
187
	  if(arg_verbose) fprintf( stderr, "Duping: %p to %p (#%u)\n",
187
	  if(arg_verbose) fprintf( stderr, "Duping: %p to %p (#%u)\n",
188
	    peer, this, peer->request_q.GetRequestIdx() );
188
	    peer, this, peer->request_q.GetRequestIdx() );
189
	  return (request_q.CopyShuffle(peer->request_q) < 0) ?
189
	  return (request_q.CopyShuffle(&peer->request_q) < 0) ?
190
	     -1 : SendRequest();
190
	     -1 : SendRequest();
191
        }else{	// not endgame mode
191
        }else{	// not endgame mode
192
	  btPeer *peer = WORLD.Who_Can_Abandon(this); // slowest choice
192
	  btPeer *peer = WORLD.Who_Can_Abandon(this); // slowest choice
Lines 194-200 Link Here
194
	    // Cancel a request to the slowest peer & request it from this one.
194
	    // Cancel a request to the slowest peer & request it from this one.
195
	    if(arg_verbose) fprintf( stderr, "Reassigning %p to %p (#%u)\n",
195
	    if(arg_verbose) fprintf( stderr, "Reassigning %p to %p (#%u)\n",
196
	      peer, this, peer->request_q.GetRequestIdx() );
196
	      peer, this, peer->request_q.GetRequestIdx() );
197
	    peer->StopDLTimer();
198
	    // RequestQueue class "moves" rather than "copies" in assignment!
197
	    // RequestQueue class "moves" rather than "copies" in assignment!
199
	    request_q = peer->request_q;
198
	    request_q = peer->request_q;
200
199
Lines 500-505 Link Here
500
    if(m_state.local_interested && SetLocal(M_NOT_INTERESTED) < 0) return -1;
499
    if(m_state.local_interested && SetLocal(M_NOT_INTERESTED) < 0) return -1;
501
  
500
  
502
  if(!request_q.IsEmpty()) StartDLTimer();
501
  if(!request_q.IsEmpty()) StartDLTimer();
502
  else StopDLTimer();
503
  return 0;
503
  return 0;
504
}
504
}
505
505
Lines 690-696 Link Here
690
    Self.StartULTimer();
690
    Self.StartULTimer();
691
  }
691
  }
692
692
693
  for(; !reponse_q.IsEmpty() && CouldReponseSlice() && !BandWidthLimitUp(); )
693
  if( !reponse_q.IsEmpty() && CouldReponseSlice() && !BandWidthLimitUp() )
694
    if( ReponseSlice() < 0) return -1;
694
    if( ReponseSlice() < 0) return -1;
695
695
696
  return (!m_state.remote_choked && request_q.IsEmpty()) ? RequestCheck() : 0;
696
  return (!m_state.remote_choked && request_q.IsEmpty()) ? RequestCheck() : 0;
(-)peerlist.cpp.dnh1 (-2 / +2 lines)
Lines 721-727 Link Here
721
//    if(loster->GetLastUnchokeTime() < peer_array[MAX_UNCHOKE]->GetLastUnchokeTime()) {
721
//    if(loster->GetLastUnchokeTime() < peer_array[MAX_UNCHOKE]->GetLastUnchokeTime()) {
722
      // if loser is empty and current is not, loser gets 75% chance.
722
      // if loser is empty and current is not, loser gets 75% chance.
723
      if( loster->bitfield.IsEmpty() && !peer_array[MAX_UNCHOKE]->bitfield.IsEmpty()
723
      if( loster->bitfield.IsEmpty() && !peer_array[MAX_UNCHOKE]->bitfield.IsEmpty()
724
            && random()&03 ) {
724
            && random()&3 ) {
725
        btPeer* tmp = peer_array[MAX_UNCHOKE];
725
        btPeer* tmp = peer_array[MAX_UNCHOKE];
726
        peer_array[MAX_UNCHOKE] = loster;
726
        peer_array[MAX_UNCHOKE] = loster;
727
        loster = tmp;
727
        loster = tmp;
Lines 732-738 Link Here
732
        // transformed to: if loser is empty or current isn't, or 25% chance,
732
        // transformed to: if loser is empty or current isn't, or 25% chance,
733
        //    then loser wins.
733
        //    then loser wins.
734
        if( !peer_array[MAX_UNCHOKE]->bitfield.IsEmpty() || loster->bitfield.IsEmpty()
734
        if( !peer_array[MAX_UNCHOKE]->bitfield.IsEmpty() || loster->bitfield.IsEmpty()
735
            || !random()&03 ) {
735
            || !(random()&3) ) {
736
          btPeer* tmp = peer_array[MAX_UNCHOKE];
736
          btPeer* tmp = peer_array[MAX_UNCHOKE];
737
          peer_array[MAX_UNCHOKE] = loster;
737
          peer_array[MAX_UNCHOKE] = loster;
738
          loster = tmp;
738
          loster = tmp;
(-)tracker.cpp.dnh1 (-1 / +3 lines)
Lines 109-120 Link Here
109
    return -1;
109
    return -1;
110
  }
110
  }
111
111
112
  m_peers_count = 0;
113
112
  if(!decode_query(buf,bufsiz,"interval",(const char**) 0,&i,QUERY_INT)){return -1;}
114
  if(!decode_query(buf,bufsiz,"interval",(const char**) 0,&i,QUERY_INT)){return -1;}
113
115
114
  if(m_interval != (time_t)i) m_interval = (time_t)i;
116
  if(m_interval != (time_t)i) m_interval = (time_t)i;
115
117
116
  if(decode_query(buf,bufsiz,"complete",(const char**) 0,&i,QUERY_INT)) {
118
  if(decode_query(buf,bufsiz,"complete",(const char**) 0,&i,QUERY_INT)) {
117
    m_peers_count = i;
119
    m_peers_count += i;
118
  }
120
  }
119
  if(decode_query(buf,bufsiz,"incomplete",(const char**) 0,&i,QUERY_INT)) {
121
  if(decode_query(buf,bufsiz,"incomplete",(const char**) 0,&i,QUERY_INT)) {
120
    m_peers_count += i;
122
    m_peers_count += i;

Return to bug 112352