Changeset 3095


Ignore:
Timestamp:
Sep 17, 2007, 1:09:48 PM (15 years ago)
Author:
charles
Message:

fix a couple of bugs I introduced yesterday.

Location:
branches/encryption/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/encryption/libtransmission/peer-mgr.c

    r3094 r3095  
    347347#if 0
    348348fprintf (stderr, "new pool: ");
    349 for (i=0; i<15 && i<poolSize; ++i ) fprintf (stderr, "%d, ", pool[i] );
     349for (i=0; i<15 && i<(int)poolSize; ++i ) fprintf (stderr, "%d, ", (int)pool[i] );
    350350fprintf (stderr, "\n");
    351351#endif
     
    362362    uint32_t pieceCount;
    363363    uint32_t * pieces;
    364     uint64_t *req, *unreq, *ret;
     364    uint64_t *req, *unreq, *ret, *walk;
    365365    int reqCount, unreqCount;
    366366    const tr_torrent * tor = t->tor;
     
    388388    }
    389389
    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;
     390fprintf( 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;
    396398
    397399    tr_free( req );
     
    651653                  int              pexCount )
    652654{
    653     int i;
    654     const tr_pex * walk = pex;
    655655    Torrent * t = getExistingTorrent( manager, torrentHash );
    656     for( i=0; i<pexCount; ++i )
     656    const tr_pex * end = pex + pexCount;
     657    while( pex != end )
    657658    {
    658659        int isNew;
    659         tr_peer * peer = getPeer( t, &walk->in_addr, &isNew );
     660        tr_peer * peer = getPeer( t, &pex->in_addr, &isNew );
    660661        if( isNew ) {
    661             peer->port = walk->port;
     662            peer->port = pex->port;
    662663            peer->from = from;
    663664            maybeConnect( manager, t, peer );
    664665        }
     666        ++pex;
    665667    }
    666668}
  • branches/encryption/libtransmission/peer-msgs.c

    r3094 r3095  
    231231    const uint32_t len = sizeof(uint8_t);
    232232    const uint8_t bt_msgid = weAreInterested ? BT_INTERESTED : BT_NOT_INTERESTED;
     233const time_t now = time( NULL );
    233234
    234235    assert( msgs != NULL );
     
    236237
    237238    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) );
    239240    tr_peerIoWriteUint32( msgs->io, msgs->outMessages, len );
    240241    tr_peerIoWriteBytes( msgs->io, msgs->outMessages, &bt_msgid, 1 );
     
    257258    assert( msgs->info != NULL );
    258259    assert( choke==0 || choke==1 );
     260const time_t now = time( NULL );
    259261
    260262    if( msgs->info->peerIsChoked != choke )
     
    270272        }
    271273
    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) );
    273275        tr_peerIoWriteUint32( msgs->io, msgs->outMessages, len );
    274276        tr_peerIoWriteBytes( msgs->io, msgs->outMessages, &bt_msgid, 1 );
     
    530532    uint32_t ui32;
    531533    uint32_t msglen = msgs->incomingMessageLength;
     534const time_t now = time( NULL );
    532535
    533536    if( EVBUFFER_LENGTH(inbuf) < msglen )
     
    543546        case BT_CHOKE:
    544547            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) );
    546549            msgs->info->clientIsChoked = 1;
    547550            tr_list_foreach( msgs->peerAskedFor, tr_free );
    548551            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 );
    550554            break;
    551555
    552556        case BT_UNCHOKE:
    553557            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) );
    555559            msgs->info->clientIsChoked = 0;
    556560            fireNeedReq( msgs );
     
    559563        case BT_INTERESTED:
    560564            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) );
    562566            msgs->info->peerIsInterested = 1;
    563567            break;
     
    565569        case BT_NOT_INTERESTED:
    566570            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) );
    568572            msgs->info->peerIsInterested = 0;
    569573            break;
     
    736740    const int block = _tr_block( tor, index, offset );
    737741    struct peer_request key, *req;
     742    const time_t now = time( NULL );
    738743
    739744    /**
     
    746751    req = (struct peer_request*) tr_list_remove( &msgs->clientAskedFor, &key,
    747752                                                 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) );
    750755    if( req == NULL ) {
    751756        gotUnwantedBlock( msgs, index, offset, length );
Note: See TracChangeset for help on using the changeset viewer.