Ignore:
Timestamp:
Dec 20, 2007, 9:44:16 PM (14 years ago)
Author:
charles
Message:

added tr_torrentSetPeerLimits(), tr_torrentGetPeerLimits(), tr_setGlobalPeerLimit(), tr_getGlobalPeerLimit()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r4179 r4255  
    8787enum
    8888{
    89     TR_MAX_SOCKETS = 512,
     89    TR_MAX_PEER_SOCKETS = 512,
    9090
    9191    TR_MAX_OPEN_FILES = 16, /* real files, not sockets */
     
    455455tr_fdInit( void )
    456456{
    457     int i, j, s[TR_MAX_SOCKETS];
     457    int i, j, s[TR_MAX_PEER_SOCKETS];
    458458
    459459    assert( gFd == NULL );
     
    463463
    464464    /* count the max number of sockets we can use */
    465     for( i=0; i<TR_MAX_SOCKETS; ++i )
     465    for( i=0; i<TR_MAX_PEER_SOCKETS; ++i )
    466466        if( ( s[i] = socket( AF_INET, SOCK_STREAM, 0 ) ) < 0 )
    467467            break;
     
    492492    tr_free( gFd );
    493493}
     494
     495void
     496tr_fdSetPeerLimit( uint16_t n )
     497{
     498    assert( gFd!=NULL && "tr_fdInit() must be called first!" );
     499    gFd->normalMax = n;
     500}
     501
     502uint16_t
     503tr_fdGetPeerLimit( void )
     504{
     505    return gFd ? gFd->normalMax : TR_MAX_PEER_SOCKETS;
     506}
Note: See TracChangeset for help on using the changeset viewer.