Ignore:
Timestamp:
Mar 1, 2009, 1:56:22 PM (13 years ago)
Author:
charles
Message:

(trunk libT) #1823: Ratio limit is only checked when peers are active

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/session.c

    r7888 r7977  
    344344
    345345    assert( tr_bencIsDict( settings ) );
    346  
     346
    347347    filename = tr_buildPath( configDir, "settings.json", NULL );
    348348
     
    724724
    725725static void
     726updateSeedRatio( tr_session * session )
     727{
     728    tr_torrent * tor = NULL;
     729
     730    while(( tor = tr_torrentNext( session, tor )))
     731        tr_torrentCheckSeedRatio( tor );
     732}
     733
     734void
     735tr_sessionSetRatioLimited( tr_session * session, tr_bool isLimited )
     736{
     737    assert( tr_isSession( session ) );
     738
     739    session->isRatioLimited = isLimited;
     740    updateSeedRatio( session );
     741}
     742
     743void
     744tr_sessionSetRatioLimit( tr_session * session, double desiredRatio )
     745{
     746    assert( tr_isSession( session ) );
     747
     748    session->desiredRatio = desiredRatio;
     749    updateSeedRatio( session );
     750}
     751
     752tr_bool
     753tr_sessionIsRatioLimited( const tr_session  * session )
     754{
     755    assert( tr_isSession( session ) );
     756
     757    return session->isRatioLimited;
     758}
     759
     760double
     761tr_sessionGetRatioLimit( const tr_session * session )
     762{
     763    assert( tr_isSession( session ) );
     764
     765    return session->desiredRatio;
     766}
     767
     768/***
     769****
     770***/
     771
     772static void
    726773updateBandwidth( tr_session * session, tr_direction dir )
    727774{
     
    750797
    751798void
    752 tr_sessionSetRatioLimited( tr_session      * session,
    753                            tr_bool           isLimited )
    754 {
    755     assert( tr_isSession( session ) );
    756    
    757     session->isRatioLimited = isLimited;
    758 }
    759 
    760 void
    761799tr_sessionSetSpeedLimit( tr_session    * session,
    762800                         tr_direction    dir,
     
    770808}
    771809
    772 void
    773 tr_sessionSetRatioLimit( tr_session    * session,
    774                          double          desiredRatio )
    775 {
    776     assert( tr_isSession( session ) );
    777 
    778     session->desiredRatio = desiredRatio;
    779 }
    780 
    781810tr_bool
    782 tr_sessionIsSpeedLimitEnabled( const tr_session  * session,
    783                                tr_direction        dir )
     811tr_sessionIsSpeedLimitEnabled( const tr_session * session, tr_direction dir )
    784812{
    785813    assert( tr_isSession( session ) );
     
    789817}
    790818
    791 tr_bool
    792 tr_sessionIsRatioLimited( const tr_session  * session )
    793 {
    794     assert( tr_isSession( session ) );
    795 
    796     return session->isRatioLimited;
    797 }
    798 
    799819int
    800 tr_sessionGetSpeedLimit( const tr_session  * session,
    801                          tr_direction        dir )
     820tr_sessionGetSpeedLimit( const tr_session * session, tr_direction dir )
    802821{
    803822    assert( tr_isSession( session ) );
     
    805824
    806825    return session->speedLimit[dir];
    807 }
    808 
    809 double
    810 tr_sessionGetRatioLimit( const tr_session  * session )
    811 {
    812     assert( tr_isSession( session ) );
    813 
    814     return session->desiredRatio;
    815826}
    816827
     
    820831
    821832void
    822 tr_sessionSetPeerLimit( tr_session * session,
    823                         uint16_t     maxGlobalPeers )
     833tr_sessionSetPeerLimit( tr_session * session, uint16_t maxGlobalPeers )
    824834{
    825835    assert( tr_isSession( session ) );
Note: See TracChangeset for help on using the changeset viewer.