Changeset 2982
- Timestamp:
- Sep 6, 2007, 9:00:39 PM (15 years ago)
- Location:
- branches/encryption/libtransmission
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/encryption/libtransmission/list.c
r2942 r2982 137 137 } 138 138 } 139 140 int 141 tr_list_size( const tr_list * list ) 142 { 143 int ret = 0; 144 145 while( list ) 146 { 147 ++list; 148 list = list->next; 149 } 150 151 return ret; 152 } -
branches/encryption/libtransmission/list.h
r2942 r2982 24 24 typedef int (*TrListCompareFunc)(const void * a, const void * b); 25 25 typedef void (*TrListForeachFunc)(void *); 26 27 int tr_list_size ( const tr_list * list ); 26 28 27 29 void tr_list_free ( tr_list ** list ); -
branches/encryption/libtransmission/peer-msgs.c
r2978 r2982 44 44 #define PEX_INTERVAL (MINUTES_TO_MSEC(1)) 45 45 46 /* the most requests we'll batch up for this peer */ 47 #define MAX_OUT_REQUESTS 10 48 46 49 enum 47 50 { … … 112 115 struct evbuffer * inBlock; /* the block we're currently receiving */ 113 116 tr_list * peerAskedFor; 114 tr_list * outPieces;117 tr_list * clientAskedFor; 115 118 116 119 tr_timer_tag pulseTag; … … 213 216 tr_peerIoWriteBytes( peer->io, peer->outMessages, &bt_msgid, 1 ); 214 217 } 218 } 219 220 /** 221 *** 222 **/ 223 224 int 225 tr_peerMsgsAddRequest( tr_peermsgs * peer, 226 uint32_t index, 227 uint32_t begin, 228 uint32_t length ) 229 { 230 int ret =-1; 231 232 if( tr_list_size(peer->clientAskedFor) < MAX_OUT_REQUESTS ) 233 { 234 const uint8_t bt_msgid = BT_REQUEST; 235 const uint32_t len = sizeof(uint8_t) + 3 * sizeof(uint32_t); 236 struct peer_request * req = tr_new( peer_request, 1 ); 237 238 tr_peerIoWriteUint32( peer->io, peer->outMessages, len ); 239 tr_peerIoWriteBytes( peer->io, peer->outMessages, &bt_msgid, 1 ); 240 tr_peerIoWriteUint32( peer->io, peer->outMessages, index ); 241 tr_peerIoWriteUint32( peer->io, peer->outMessages, begin ); 242 tr_peerIoWriteUint32( peer->io, peer->outMessages, length ); 243 fprintf( stderr, "peer %p: requesting a block from piece %u, begin %u, length %u\n", 244 peer, (unsigned int)index, (unsigned int)begin, (unsigned int)length ); 245 246 req->index = index; 247 req->begin = begin; 248 req->length = length; 249 tr_list_append( &peer->clientAskedFor, req ); 250 251 ret = 0; 252 } 253 254 return ret; 215 255 } 216 256 … … 497 537 } 498 538 539 static int 540 weAskedForThisBlock( const tr_peermsgs * peer, uint32_t index, uint32_t offset, uint32_t 541 499 542 static void 500 543 gotBlock( tr_peermsgs * peer, int index, int offset, struct evbuffer * inbuf ) … … 513 556 return; 514 557 } 558 559 cc 560 struct peer_request 561 { 562 uint32_t index; 563 uint32_t offset; 564 uint32_t length; 565 }; 566 567 568 tr_list_append( &peer->clientAskedFor, req ); 569 570 ccc 571 --peer->outReqCount; 515 572 516 573 /* write to disk */ -
branches/encryption/libtransmission/peer-msgs.h
r2968 r2982 26 26 void tr_peerMsgsFree( tr_peermsgs* ); 27 27 28 int tr_peerMsgsAddRequest( tr_peermsgs * peer, 29 uint32_t index, 30 uint32_t begin, 31 uint32_t length ); 32 33 28 34 #endif
Note: See TracChangeset
for help on using the changeset viewer.