Changeset 2590


Ignore:
Timestamp:
Aug 2, 2007, 4:07:34 PM (15 years ago)
Author:
charles
Message:

use a straight lock, rather than a rwlock, for rate control

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/ratecontrol.c

    r2573 r2590  
    4545struct tr_ratecontrol_s
    4646{
    47     tr_rwlock_t * lock;
     47    tr_lock_t * lock;
    4848    int limit;
    4949    int newest;
     
    8181    tr_ratecontrol_t * r = tr_new0( tr_ratecontrol_t, 1 );
    8282    r->limit = 0;
    83     r->lock = tr_rwNew( );
     83    r->lock = tr_lockNew( );
    8484    return r;
    8585}
     
    8989{
    9090    tr_rcReset( r );
    91     tr_rwFree( r->lock );
     91    tr_lockFree( r->lock );
    9292    tr_free( r );
    9393}
     
    101101{
    102102    int ret;
    103     tr_rwReaderLock( (tr_rwlock_t*)r->lock );
     103    tr_lockLock( (tr_lock_t*)r->lock );
    104104
    105105    ret = rateForInterval( r, SHORT_INTERVAL_MSEC ) < r->limit;
    106106
    107     tr_rwReaderUnlock( (tr_rwlock_t*)r->lock );
     107    tr_lockUnlock( (tr_lock_t*)r->lock );
    108108    return ret;
    109109}
     
    113113{
    114114    float ret;
    115     tr_rwReaderLock( (tr_rwlock_t*)r->lock );
     115    tr_lockLock( (tr_lock_t*)r->lock );
    116116
    117117    ret = rateForInterval( r, LONG_INTERVAL_MSEC );
    118118
    119     tr_rwReaderUnlock( (tr_rwlock_t*)r->lock );
     119    tr_lockUnlock( (tr_lock_t*)r->lock );
    120120    return ret;
    121121}
     
    133133        return;
    134134   
    135     tr_rwWriterLock( r->lock );
     135    tr_lockLock( (tr_lock_t*)r->lock );
    136136
    137137    now = tr_date ();
     
    144144    }
    145145
    146     tr_rwWriterUnlock( r->lock );
     146    tr_lockUnlock( (tr_lock_t*)r->lock );
    147147}
    148148
     
    150150tr_rcReset( tr_ratecontrol_t * r )
    151151{
    152     tr_rwWriterLock( r->lock );
     152    tr_lockLock( (tr_lock_t*)r->lock );
    153153    r->newest = 0;
    154154    memset( r->transfers, 0, sizeof(tr_transfer_t) * HISTORY_SIZE );
    155     tr_rwWriterUnlock( r->lock );
     155    tr_lockUnlock( (tr_lock_t*)r->lock );
    156156}
    157157
     
    159159tr_rcSetLimit( tr_ratecontrol_t * r, int limit )
    160160{
    161     tr_rwWriterLock( r->lock );
     161    tr_lockLock( (tr_lock_t*)r->lock );
    162162    r->limit = limit;
    163     tr_rwWriterUnlock( r->lock );
     163    tr_lockUnlock( (tr_lock_t*)r->lock );
    164164}
    165165
Note: See TracChangeset for help on using the changeset viewer.