Changeset 3095
- Timestamp:
- Sep 17, 2007, 1:09:48 PM (15 years ago)
- Location:
- branches/encryption/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/encryption/libtransmission/peer-mgr.c
r3094 r3095 347 347 #if 0 348 348 fprintf (stderr, "new pool: "); 349 for (i=0; i<15 && i< poolSize; ++i ) fprintf (stderr, "%d, ",pool[i] );349 for (i=0; i<15 && i<(int)poolSize; ++i ) fprintf (stderr, "%d, ", (int)pool[i] ); 350 350 fprintf (stderr, "\n"); 351 351 #endif … … 362 362 uint32_t pieceCount; 363 363 uint32_t * pieces; 364 uint64_t *req, *unreq, *ret ;364 uint64_t *req, *unreq, *ret, *walk; 365 365 int reqCount, unreqCount; 366 366 const tr_torrent * tor = t->tor; … … 388 388 } 389 389 390 fprintf( stderr, "REFILL refillPulse for {%s} reqCount is %d\n", tor->info.name, (int)reqCount ); 391 fprintf( stderr, "REFILL refillPulse for {%s} unreqCount is %d\n", tor->info.name, (int)unreqCount ); 392 ret = tr_new( uint64_t, unreqCount + reqCount ); 393 memcpy( ret, unreq, sizeof(uint64_t) * unreqCount ); 394 memcpy( ret, req, sizeof(uint64_t) * reqCount ); 395 *setmeCount = unreqCount + reqCount; 390 fprintf( stderr, "REFILL refillPulse for {%s} reqCount is %d, unreqCount is %d\n", tor->info.name, (int)reqCount, (int)unreqCount ); 391 ret = walk = tr_new( uint64_t, unreqCount + reqCount ); 392 memcpy( walk, unreq, sizeof(uint64_t) * unreqCount ); 393 walk += unreqCount; 394 memcpy( walk, req, sizeof(uint64_t) * reqCount ); 395 walk += reqCount; 396 assert( ( walk - ret ) == ( unreqCount + reqCount ) ); 397 *setmeCount = walk - ret; 396 398 397 399 tr_free( req ); … … 651 653 int pexCount ) 652 654 { 653 int i;654 const tr_pex * walk = pex;655 655 Torrent * t = getExistingTorrent( manager, torrentHash ); 656 for( i=0; i<pexCount; ++i ) 656 const tr_pex * end = pex + pexCount; 657 while( pex != end ) 657 658 { 658 659 int isNew; 659 tr_peer * peer = getPeer( t, & walk->in_addr, &isNew );660 tr_peer * peer = getPeer( t, &pex->in_addr, &isNew ); 660 661 if( isNew ) { 661 peer->port = walk->port;662 peer->port = pex->port; 662 663 peer->from = from; 663 664 maybeConnect( manager, t, peer ); 664 665 } 666 ++pex; 665 667 } 666 668 } -
branches/encryption/libtransmission/peer-msgs.c
r3094 r3095 231 231 const uint32_t len = sizeof(uint8_t); 232 232 const uint8_t bt_msgid = weAreInterested ? BT_INTERESTED : BT_NOT_INTERESTED; 233 const time_t now = time( NULL ); 233 234 234 235 assert( msgs != NULL ); … … 236 237 237 238 msgs->info->clientIsInterested = weAreInterested; 238 fprintf( stderr, "peer %p: sending an %s message \n", msgs, (weAreInterested ? "INTERESTED" : "NOT_INTERESTED") );239 fprintf( stderr, "peer %p: sending an %s message at %s\n", msgs, (weAreInterested ? "INTERESTED" : "NOT_INTERESTED"), ctime(&now) ); 239 240 tr_peerIoWriteUint32( msgs->io, msgs->outMessages, len ); 240 241 tr_peerIoWriteBytes( msgs->io, msgs->outMessages, &bt_msgid, 1 ); … … 257 258 assert( msgs->info != NULL ); 258 259 assert( choke==0 || choke==1 ); 260 const time_t now = time( NULL ); 259 261 260 262 if( msgs->info->peerIsChoked != choke ) … … 270 272 } 271 273 272 fprintf( stderr, "peer %p: sending a %s message \n", msgs, (choke ? "CHOKE" : "UNCHOKE") );274 fprintf( stderr, "peer %p: sending a %s message at %s\n", msgs, (choke ? "CHOKE" : "UNCHOKE"), ctime(&now) ); 273 275 tr_peerIoWriteUint32( msgs->io, msgs->outMessages, len ); 274 276 tr_peerIoWriteBytes( msgs->io, msgs->outMessages, &bt_msgid, 1 ); … … 530 532 uint32_t ui32; 531 533 uint32_t msglen = msgs->incomingMessageLength; 534 const time_t now = time( NULL ); 532 535 533 536 if( EVBUFFER_LENGTH(inbuf) < msglen ) … … 543 546 case BT_CHOKE: 544 547 assert( msglen == 0 ); 545 fprintf( stderr, "w00t peer-msgs %p sent us a BT_CHOKE \n", msgs);548 fprintf( stderr, "w00t peer-msgs %p sent us a BT_CHOKE at %s\n", msgs, ctime(&now) ); 546 549 msgs->info->clientIsChoked = 1; 547 550 tr_list_foreach( msgs->peerAskedFor, tr_free ); 548 551 tr_list_free( &msgs->peerAskedFor ); 549 /* FIXME: unmark anything we'd requested from them... */ 552 tr_list_foreach( msgs->clientAskedFor, tr_free ); 553 tr_list_free( &msgs->clientAskedFor ); 550 554 break; 551 555 552 556 case BT_UNCHOKE: 553 557 assert( msglen == 0 ); 554 fprintf( stderr, "w00t peer-msgs %p sent us a BT_UNCHOKE \n", msgs);558 fprintf( stderr, "w00t peer-msgs %p sent us a BT_UNCHOKE at %s\n", msgs, ctime(&now) ); 555 559 msgs->info->clientIsChoked = 0; 556 560 fireNeedReq( msgs ); … … 559 563 case BT_INTERESTED: 560 564 assert( msglen == 0 ); 561 fprintf( stderr, "w00t peer-msgs %p sent us a BT_INTERESTED \n", msgs);565 fprintf( stderr, "w00t peer-msgs %p sent us a BT_INTERESTED at %s\n", msgs, ctime(&now) ); 562 566 msgs->info->peerIsInterested = 1; 563 567 break; … … 565 569 case BT_NOT_INTERESTED: 566 570 assert( msglen == 0 ); 567 fprintf( stderr, "w00t peer-msgs %p sent us a BT_NOT_INTERESTED \n", msgs);571 fprintf( stderr, "w00t peer-msgs %p sent us a BT_NOT_INTERESTED at %s\n", msgs, ctime(&now) ); 568 572 msgs->info->peerIsInterested = 0; 569 573 break; … … 736 740 const int block = _tr_block( tor, index, offset ); 737 741 struct peer_request key, *req; 742 const time_t now = time( NULL ); 738 743 739 744 /** … … 746 751 req = (struct peer_request*) tr_list_remove( &msgs->clientAskedFor, &key, 747 752 peer_request_compare ); 748 fprintf( stderr, "w00t got a block from %p. turnaround time for this block was %d seconds \n",749 msgs, (int)(time(NULL) - req->time_requested) );753 fprintf( stderr, "w00t got a block from %p. turnaround time for this block was %d seconds... at %s\n", 754 msgs, (int)(time(NULL) - req->time_requested), ctime(&now) ); 750 755 if( req == NULL ) { 751 756 gotUnwantedBlock( msgs, index, offset, length );
Note: See TracChangeset
for help on using the changeset viewer.