Changeset 9381


Ignore:
Timestamp:
Oct 22, 2009, 3:05:56 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #2508: atom->port never updated

Location:
trunk/libtransmission
Files:
6 edited

Legend:

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

    r9328 r9381  
    276276    const tr_peer * b = vb;
    277277
    278     return tr_compareAddresses( &a->addr, &b->addr );
     278    return tr_compareAddresses( &a->atom->addr, &b->atom->addr );
    279279}
    280280
     
    284284    const tr_peer * a = va;
    285285
    286     return tr_compareAddresses( &a->addr, vb );
     286    return tr_compareAddresses( &a->atom->addr, vb );
    287287}
    288288
     
    320320
    321321static tr_peer*
    322 peerConstructor( const tr_address * addr )
    323 {
    324     tr_peer * p;
    325     p = tr_new0( tr_peer, 1 );
    326     p->addr = *addr;
    327     return p;
     322peerConstructor( void )
     323{
     324    return tr_new0( tr_peer, 1 );
    328325}
    329326
     
    340337    if( peer == NULL )
    341338    {
    342         peer = peerConstructor( addr );
     339        peer = peerConstructor( );
    343340        tr_ptrArrayInsertSorted( &torrent->peers, peer, peerCompare );
    344341    }
     
    925922{
    926923    tordbg( t, "increasing peer %s strike count to %d",
    927             tr_peerIoAddrStr( &peer->addr,
    928                               peer->port ), peer->strikes + 1 );
     924            tr_atomAddrStr( peer->atom ), peer->strikes + 1 );
    929925
    930926    if( ++peer->strikes >= MAX_BAD_PIECES_PER_PEER )
     
    933929        atom->myflags |= MYFLAG_BANNED;
    934930        peer->doPurge = 1;
    935         tordbg( t, "banning peer %s", tr_peerIoAddrStr( &atom->addr, atom->port ) );
     931        tordbg( t, "banning peer %s", tr_atomAddrStr( atom ) );
    936932    }
    937933}
     
    11051101                struct peer_atom * atom = peer->atom;
    11061102                if( e->progress >= 1.0 ) {
    1107                     tordbg( t, "marking peer %s as a seed", tr_peerIoAddrStr( &atom->addr, atom->port ) );
     1103                    tordbg( t, "marking peer %s as a seed", tr_atomAddrStr( atom ) );
    11081104                    atom->flags |= ADDED_F_SEED_FLAG;
    11091105                }
     
    11721168                peer->doPurge = 1;
    11731169                tordbg( t, "setting %s doPurge flag because we got an ERANGE, EMSGSIZE, or ENOTCONN error",
    1174                         tr_peerIoAddrStr( &peer->addr, peer->port ) );
     1170                        tr_atomAddrStr( peer->atom ) );
    11751171            }
    11761172            else
     
    12051201        a->flags = flags;
    12061202        a->from = from;
    1207         tordbg( t, "got a new atom: %s", tr_peerIoAddrStr( &a->addr, a->port ) );
     1203        tordbg( t, "got a new atom: %s", tr_atomAddrStr( a ) );
    12081204        tr_ptrArrayInsertSorted( &t->pool, a, comparePeerAtoms );
    12091205    }
     
    12811277        if( atom->myflags & MYFLAG_BANNED )
    12821278        {
    1283             tordbg( t, "banned peer %s tried to reconnect",
    1284                     tr_peerIoAddrStr( &atom->addr, atom->port ) );
     1279            tordbg( t, "banned peer %s tried to reconnect", tr_atomAddrStr( atom ) );
    12851280        }
    12861281        else if( tr_peerIoIsIncoming( io )
     
    13091304                }
    13101305
    1311                 peer->port = port;
    13121306                peer->atom = atom;
    13131307                peer->io = tr_handshakeStealIO( handshake ); /* this steals its refcount too, which is
     
    14851479            {
    14861480                tordbg( t, "peer %s contributed to corrupt piece (%d); now has %d strikes",
    1487                         tr_peerIoAddrStr( &peer->addr, peer->port ),
     1481                        tr_atomAddrStr( peer->atom ),
    14881482                        pieceIndex, (int)peer->strikes + 1 );
    14891483                addStrike( t, peer );
     
    18831877        tr_peer_stat *           stat = ret + i;
    18841878
    1885         tr_ntop( &peer->addr, stat->addr, sizeof( stat->addr ) );
     1879        tr_ntop( &atom->addr, stat->addr, sizeof( stat->addr ) );
    18861880        tr_strlcpy( stat->client, ( peer->client ? peer->client : "" ),
    18871881                   sizeof( stat->client ) );
    1888         stat->port               = ntohs( peer->port );
     1882        stat->port               = ntohs( atom->port );
    18891883        stat->from               = atom->from;
    18901884        stat->progress           = peer->progress;
     
    23932387            tr_peerIo         * io;
    23942388
    2395             tordbg( t, "Starting an OUTGOING connection with %s",
    2396                    tr_peerIoAddrStr( &atom->addr, atom->port ) );
     2389            tordbg( t, "Starting an OUTGOING connection with %s", tr_atomAddrStr( atom ) );
    23972390
    23982391            io = tr_peerIoNewOutgoing( mgr->session, mgr->session->bandwidth, &atom->addr, atom->port, t->tor->info.hash );
     
    24012394            {
    24022395                tordbg( t, "peerIo not created; marking peer %s as unreachable",
    2403                         tr_peerIoAddrStr( &atom->addr, atom->port ) );
     2396                        tr_atomAddrStr( atom ) );
    24042397                atom->myflags |= MYFLAG_UNREACHABLE;
    24052398            }
     
    26442637    return TRUE;
    26452638}
     2639
     2640/***
     2641****
     2642***/
     2643
     2644tr_port
     2645tr_atomGetPort( const struct peer_atom * atom )
     2646{
     2647    assert( tr_isAtom( atom ) );
     2648
     2649    return atom->port;
     2650}
     2651
     2652void
     2653tr_atomSetPort( struct peer_atom * atom, tr_port port )
     2654{
     2655    assert( tr_isAtom( atom ) );
     2656
     2657    atom->port = port;
     2658}
     2659
     2660const char *
     2661tr_atomAddrStr( const struct peer_atom * atom )
     2662{
     2663    assert( tr_isAtom( atom ) );
     2664
     2665    return tr_peerIoAddrStr( &atom->addr, atom->port );
     2666}
     2667
     2668const tr_address *
     2669tr_atomGetAddr( const struct peer_atom * atom )
     2670{
     2671    assert( tr_isAtom( atom ) );
     2672
     2673    return &atom->addr;
     2674}
  • trunk/libtransmission/peer-mgr.h

    r9085 r9381  
    6060struct tr_peermsgs;
    6161
     62/**
     63***
     64**/
     65
     66/* opaque forward declaration */
     67struct peer_atom;
     68
     69const tr_address* tr_atomGetAddr( const struct peer_atom * );
     70
     71tr_port tr_atomGetPort( const struct peer_atom * atom );
     72
     73void tr_atomSetPort( struct peer_atom * atom, tr_port port );
     74
     75const char* tr_atomAddrStr( const struct peer_atom * );
     76
     77/**
     78***
     79**/
     80
    6281enum
    6382{
     
    6685    ENCRYPTION_PREFERENCE_NO
    6786};
    68 
    69 /* opaque forward declaration */
    70 struct peer_atom;
    7187
    7288/**
     
    88104
    89105    uint8_t                  encryption_preference;
    90     tr_port                  port;
    91106    tr_port                  dht_port;
    92     tr_address               addr;
    93107    struct tr_peerIo       * io;
    94108    struct peer_atom       * atom;
     
    110124tr_peer;
    111125
     126/**
     127***
     128**/
    112129
    113130int tr_pexCompare( const void * a, const void * b );
  • trunk/libtransmission/peer-msgs.c

    r9239 r9381  
    10601060    /* get peer's listening port */
    10611061    if( tr_bencDictFindInt( &val, "p", &i ) ) {
    1062         msgs->peer->port = htons( (uint16_t)i );
    1063         dbgmsg( msgs, "msgs->port is now %hu", msgs->peer->port );
     1062        tr_atomSetPort( msgs->peer->atom, htons( (uint16_t)i ) );
     1063        dbgmsg( msgs, "msgs->port is now %hu", tr_atomGetPort( msgs->peer->atom ) );
    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), &msgs->peer->addr, msgs->peer->dht_port, 0 );
     1458                tr_dhtAddNode( getSession(msgs), tr_atomGetAddr( msgs->peer->atom ), msgs->peer->dht_port, 0 );
    14591459            break;
    14601460
  • trunk/libtransmission/tr-dht.c

    r8996 r9381  
    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                      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                     const 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, tr_address *address, tr_port port,
    323               tr_bool bootstrap)
     322tr_dhtAddNode(tr_session        * ss,
     323              const tr_address  * address,
     324              tr_port             port,
     325              tr_bool             bootstrap)
    324326{
    325327    struct sockaddr_in sin;
  • trunk/libtransmission/tr-dht.h

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

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