Ignore:
Timestamp:
Jan 12, 2006, 7:12:58 PM (16 years ago)
Author:
root
Message:

Update 2006-01-11

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peerutils.h

    r3 r26  
    2626 * peerInit
    2727 ***********************************************************************
    28  * Returns NULL if we reached the maximum authorized number of peers.
    29  * Otherwise, allocates a new tr_peer_t, add it to the peers list and
    30  * returns a pointer to it.
     28 * Allocates a new tr_peer_t and returns a pointer to it.
    3129 **********************************************************************/
    32 static tr_peer_t * peerInit( tr_torrent_t * tor )
     30static tr_peer_t * peerInit()
    3331{
    3432    tr_peer_t * peer;
    35 
    36     if( tor->peerCount >= TR_MAX_PEER_COUNT )
    37     {
    38         return NULL;
    39     }
    4033
    4134    peer              = calloc( sizeof( tr_peer_t ), 1 );
     
    4538    peer->keepAlive   = peer->date;
    4639
     40    return peer;
     41}
     42
     43/***********************************************************************
     44 * peerAttach
     45 ***********************************************************************
     46 * Deallocates the tr_peer_t and returns 0 if we reached the maximum
     47 * authorized number of peers. Otherwise, adds the tr_peer_t to the
     48 * peers list.
     49 **********************************************************************/
     50static int peerAttach( tr_torrent_t * tor, tr_peer_t * peer )
     51{
     52    if( tor->peerCount >= TR_MAX_PEER_COUNT )
     53    {
     54        tr_peerDestroy( tor->fdlimit, peer );
     55        return 0;
     56    }
     57
    4758    tor->peers[tor->peerCount++] = peer;
    48     return peer;
     59    return 1;
    4960}
    5061
     
    8495    }
    8596
    86     if( !( peer = peerInit( tor ) ) )
     97    peer = peerInit();
     98    if( !peerAttach( tor, peer ) )
    8799    {
    88100        return;
Note: See TracChangeset for help on using the changeset viewer.