Changeset 9383


Ignore:
Timestamp:
Oct 22, 2009, 7:08:45 PM (12 years ago)
Author:
charles
Message:

(trunk libT) undo today's earlier commit r9381 for #2508 -- looks like I introduced a bug into the patch.

Location:
trunk/libtransmission
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r9381 r9383  
    276276    const tr_peer * b = vb;
    277277
    278     return tr_compareAddresses( &a->atom->addr, &b->atom->addr );
     278    return tr_compareAddresses( &a->addr, &b->addr );
    279279}
    280280
     
    284284    const tr_peer * a = va;
    285285
    286     return tr_compareAddresses( &a->atom->addr, vb );
     286    return tr_compareAddresses( &a->addr, vb );
    287287}
    288288
     
    320320
    321321static tr_peer*
    322 peerConstructor( void )
    323 {
    324     return tr_new0( tr_peer, 1 );
     322peerConstructor( const tr_address * addr )
     323{
     324    tr_peer * p;
     325    p = tr_new0( tr_peer, 1 );
     326    p->addr = *addr;
     327    return p;
    325328}
    326329
     
    337340    if( peer == NULL )
    338341    {
    339         peer = peerConstructor( );
     342        peer = peerConstructor( addr );
    340343        tr_ptrArrayInsertSorted( &torrent->peers, peer, peerCompare );
    341344    }
     
    922925{
    923926    tordbg( t, "increasing peer %s strike count to %d",
    924             tr_atomAddrStr( peer->atom ), peer->strikes + 1 );
     927            tr_peerIoAddrStr( &peer->addr,
     928                              peer->port ), peer->strikes + 1 );
    925929
    926930    if( ++peer->strikes >= MAX_BAD_PIECES_PER_PEER )
     
    929933        atom->myflags |= MYFLAG_BANNED;
    930934        peer->doPurge = 1;
    931         tordbg( t, "banning peer %s", tr_atomAddrStr( atom ) );
     935        tordbg( t, "banning peer %s", tr_peerIoAddrStr( &atom->addr, atom->port ) );
    932936    }
    933937}
     
    11011105                struct peer_atom * atom = peer->atom;
    11021106                if( e->progress >= 1.0 ) {
    1103                     tordbg( t, "marking peer %s as a seed", tr_atomAddrStr( atom ) );
     1107                    tordbg( t, "marking peer %s as a seed", tr_peerIoAddrStr( &atom->addr, atom->port ) );
    11041108                    atom->flags |= ADDED_F_SEED_FLAG;
    11051109                }
     
    11681172                peer->doPurge = 1;
    11691173                tordbg( t, "setting %s doPurge flag because we got an ERANGE, EMSGSIZE, or ENOTCONN error",
    1170                         tr_atomAddrStr( peer->atom ) );
     1174                        tr_peerIoAddrStr( &peer->addr, peer->port ) );
    11711175            }
    11721176            else
     
    12011205        a->flags = flags;
    12021206        a->from = from;
    1203         tordbg( t, "got a new atom: %s", tr_atomAddrStr( a ) );
     1207        tordbg( t, "got a new atom: %s", tr_peerIoAddrStr( &a->addr, a->port ) );
    12041208        tr_ptrArrayInsertSorted( &t->pool, a, comparePeerAtoms );
    12051209    }
     
    12771281        if( atom->myflags & MYFLAG_BANNED )
    12781282        {
    1279             tordbg( t, "banned peer %s tried to reconnect", tr_atomAddrStr( atom ) );
     1283            tordbg( t, "banned peer %s tried to reconnect",
     1284                    tr_peerIoAddrStr( &atom->addr, atom->port ) );
    12801285        }
    12811286        else if( tr_peerIoIsIncoming( io )
     
    13041309                }
    13051310
     1311                peer->port = port;
    13061312                peer->atom = atom;
    13071313                peer->io = tr_handshakeStealIO( handshake ); /* this steals its refcount too, which is
     
    14791485            {
    14801486                tordbg( t, "peer %s contributed to corrupt piece (%d); now has %d strikes",
    1481                         tr_atomAddrStr( peer->atom ),
     1487                        tr_peerIoAddrStr( &peer->addr, peer->port ),
    14821488                        pieceIndex, (int)peer->strikes + 1 );
    14831489                addStrike( t, peer );
     
    18771883        tr_peer_stat *           stat = ret + i;
    18781884
    1879         tr_ntop( &atom->addr, stat->addr, sizeof( stat->addr ) );
     1885        tr_ntop( &peer->addr, stat->addr, sizeof( stat->addr ) );
    18801886        tr_strlcpy( stat->client, ( peer->client ? peer->client : "" ),
    18811887                   sizeof( stat->client ) );
    1882         stat->port               = ntohs( atom->port );
     1888        stat->port               = ntohs( peer->port );
    18831889        stat->from               = atom->from;
    18841890        stat->progress           = peer->progress;
     
    23872393            tr_peerIo         * io;
    23882394
    2389             tordbg( t, "Starting an OUTGOING connection with %s", tr_atomAddrStr( atom ) );
     2395            tordbg( t, "Starting an OUTGOING connection with %s",
     2396                   tr_peerIoAddrStr( &atom->addr, atom->port ) );
    23902397
    23912398            io = tr_peerIoNewOutgoing( mgr->session, mgr->session->bandwidth, &atom->addr, atom->port, t->tor->info.hash );
     
    23942401            {
    23952402                tordbg( t, "peerIo not created; marking peer %s as unreachable",
    2396                         tr_atomAddrStr( atom ) );
     2403                        tr_peerIoAddrStr( &atom->addr, atom->port ) );
    23972404                atom->myflags |= MYFLAG_UNREACHABLE;
    23982405            }
     
    26372644    return TRUE;
    26382645}
    2639 
    2640 /***
    2641 ****
    2642 ***/
    2643 
    2644 tr_port
    2645 tr_atomGetPort( const struct peer_atom * atom )
    2646 {
    2647     assert( tr_isAtom( atom ) );
    2648 
    2649     return atom->port;
    2650 }
    2651 
    2652 void
    2653 tr_atomSetPort( struct peer_atom * atom, tr_port port )
    2654 {
    2655     assert( tr_isAtom( atom ) );
    2656 
    2657     atom->port = port;
    2658 }
    2659 
    2660 const char *
    2661 tr_atomAddrStr( const struct peer_atom * atom )
    2662 {
    2663     assert( tr_isAtom( atom ) );
    2664 
    2665     return tr_peerIoAddrStr( &atom->addr, atom->port );
    2666 }
    2667 
    2668 const tr_address *
    2669 tr_atomGetAddr( const struct peer_atom * atom )
    2670 {
    2671     assert( tr_isAtom( atom ) );
    2672 
    2673     return &atom->addr;
    2674 }
  • trunk/libtransmission/peer-mgr.h

    r9381 r9383  
    6060struct tr_peermsgs;
    6161
    62 /**
    63 ***
    64 **/
    65 
    66 /* opaque forward declaration */
    67 struct peer_atom;
    68 
    69 const tr_address* tr_atomGetAddr( const struct peer_atom * );
    70 
    71 tr_port tr_atomGetPort( const struct peer_atom * atom );
    72 
    73 void tr_atomSetPort( struct peer_atom * atom, tr_port port );
    74 
    75 const char* tr_atomAddrStr( const struct peer_atom * );
    76 
    77 /**
    78 ***
    79 **/
    80 
    8162enum
    8263{
     
    8566    ENCRYPTION_PREFERENCE_NO
    8667};
     68
     69/* opaque forward declaration */
     70struct peer_atom;
    8771
    8872/**
     
    10488
    10589    uint8_t                  encryption_preference;
     90    tr_port                  port;
    10691    tr_port                  dht_port;
     92    tr_address               addr;
    10793    struct tr_peerIo       * io;
    10894    struct peer_atom       * atom;
     
    124110tr_peer;
    125111
    126 /**
    127 ***
    128 **/
    129112
    130113int tr_pexCompare( const void * a, const void * b );
  • trunk/libtransmission/peer-msgs.c

    r9381 r9383  
    10601060    /* get peer's listening port */
    10611061    if( tr_bencDictFindInt( &val, "p", &i ) ) {
    1062         tr_atomSetPort( msgs->peer->atom, htons( (uint16_t)i ) );
    1063         dbgmsg( msgs, "msgs->port is now %hu", tr_atomGetPort( msgs->peer->atom ) );
     1062        msgs->peer->port = htons( (uint16_t)i );
     1063        dbgmsg( msgs, "msgs->port is now %hu", msgs->peer->port );
    10641064    }
    10651065
     
    14561456            tr_peerIoReadUint16( msgs->peer->io, inbuf, &msgs->peer->dht_port );
    14571457            if( msgs->peer->dht_port > 0 )
    1458                 tr_dhtAddNode( getSession(msgs), tr_atomGetAddr( msgs->peer->atom ), msgs->peer->dht_port, 0 );
     1458                tr_dhtAddNode( getSession(msgs), &msgs->peer->addr, msgs->peer->dht_port, 0 );
    14591459            break;
    14601460
  • trunk/libtransmission/tr-dht.c

    r9381 r9383  
    6161  int tr_dhtStatus( tr_session * session     UNUSED,
    6262                    int        * setmeCount  UNUSED ) { return TR_DHT_STOPPED; }
    63   int tr_dhtAddNode( tr_session       * session    UNUSED,
    64                      const tr_address * addr       UNUSED,
    65                      tr_port            port       UNUSED,
    66                      tr_bool            bootstrap  UNUSED ) { return 0; }
     63  int tr_dhtAddNode( tr_session * session    UNUSED,
     64                     tr_address * addr       UNUSED,
     65                     tr_port      port       UNUSED,
     66                     tr_bool      bootstrap  UNUSED ) { return 0; }
    6767  int tr_dhtAnnounce( tr_torrent * session UNUSED,
    6868                      tr_bool announce UNUSED ) { return -1; }
     
    320320
    321321int
    322 tr_dhtAddNode(tr_session        * ss,
    323               const tr_address  * address,
    324               tr_port             port,
    325               tr_bool             bootstrap)
     322tr_dhtAddNode(tr_session *ss, tr_address *address, tr_port port,
     323              tr_bool bootstrap)
    326324{
    327325    struct sockaddr_in sin;
  • trunk/libtransmission/tr-dht.h

    r9381 r9383  
    3333int tr_dhtStatus( tr_session *, int * setme_nodeCount );
    3434const char *tr_dhtPrintableStatus(int status);
    35 int tr_dhtAddNode( tr_session *, const tr_address *, tr_port, tr_bool bootstrap );
     35int tr_dhtAddNode( tr_session *, tr_address *, tr_port, tr_bool bootstrap );
    3636int tr_dhtAnnounce( tr_torrent *, tr_bool announce );
  • trunk/libtransmission/web.h

    r9381 r9383  
    1313#ifndef TR_HTTP_H
    1414#define TR_HTTP_H
    15 
    16 struct tr_address;
    1715
    1816typedef struct tr_web tr_web;
Note: See TracChangeset for help on using the changeset viewer.