Changeset 3072


Ignore:
Timestamp:
Sep 15, 2007, 5:09:00 PM (15 years ago)
Author:
charles
Message:

remove dead code: rwlock

Location:
branches/encryption/libtransmission
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/encryption/libtransmission/internal.h

    r3049 r3072  
    5858void tr_torrentSetHasPiece( tr_torrent * tor, int pieceIndex, int has );
    5959
    60 void tr_torrentReaderLock    ( const tr_torrent * );
    61 void tr_torrentReaderUnlock  ( const tr_torrent * );
    62 void tr_torrentWriterLock    ( tr_torrent * );
    63 void tr_torrentWriterUnlock  ( tr_torrent * );
     60void tr_torrentLock    ( const tr_torrent * );
     61void tr_torrentUnlock  ( const tr_torrent * );
    6462
    6563void tr_torrentChangeMyPort  ( tr_torrent *, int port );
     
    145143    char                       runStatusToSaveIsSet;
    146144    cp_status_t                cpStatus;
    147     struct tr_rwlock         * lock;
     145    struct tr_lock           * lock;
    148146
    149147    struct tr_tracker        * tracker;
  • branches/encryption/libtransmission/peer-mgr.c

    r3070 r3072  
    816816    const float interval = tor->info.pieceCount / (float)tabCount;
    817817
     818    memset( tab, 0, tabCount );
     819
    818820    for( i=0; i<tabCount; ++i )
    819821    {
  • branches/encryption/libtransmission/platform.c

    r3028 r3072  
    239239
    240240/***
    241 ****  RW LOCK
    242 ***/
    243 
    244 struct tr_rwlock
    245 {
    246     tr_lock * lock;
    247     tr_cond * readCond;
    248     tr_cond * writeCond;
    249     size_t readCount;
    250     size_t wantToRead;
    251     size_t wantToWrite;
    252     int haveWriter;
    253 };
    254 
    255 static void
    256 tr_rwSignal( tr_rwlock * rw )
    257 {
    258   if ( rw->wantToWrite )
    259     tr_condSignal( rw->writeCond );
    260   else if ( rw->wantToRead )
    261     tr_condBroadcast( rw->readCond );
    262 }
    263 
    264 tr_rwlock*
    265 tr_rwNew ( void )
    266 {
    267     tr_rwlock * rw = tr_new0( tr_rwlock, 1 );
    268     rw->lock = tr_lockNew( );
    269     rw->readCond = tr_condNew( );
    270     rw->writeCond = tr_condNew( );
    271     return rw;
    272 }
    273 
    274 void
    275 tr_rwReaderLock( tr_rwlock * rw )
    276 {
    277     tr_lockLock( rw->lock );
    278     rw->wantToRead++;
    279     while( rw->haveWriter || rw->wantToWrite )
    280         tr_condWait( rw->readCond, rw->lock );
    281     rw->wantToRead--;
    282     rw->readCount++;
    283     tr_lockUnlock( rw->lock );
    284 }
    285 
    286 int
    287 tr_rwReaderTrylock( tr_rwlock * rw )
    288 {
    289     int ret = FALSE;
    290     tr_lockLock( rw->lock );
    291     if ( !rw->haveWriter && !rw->wantToWrite ) {
    292         rw->readCount++;
    293         ret = TRUE;
    294     }
    295     tr_lockUnlock( rw->lock );
    296     return ret;
    297 
    298 }
    299 
    300 void
    301 tr_rwReaderUnlock( tr_rwlock * rw )
    302 {
    303     tr_lockLock( rw->lock );
    304     --rw->readCount;
    305     if( !rw->readCount )
    306         tr_rwSignal( rw );
    307     tr_lockUnlock( rw->lock );
    308 }
    309 
    310 void
    311 tr_rwWriterLock( tr_rwlock * rw )
    312 {
    313     tr_lockLock( rw->lock );
    314     rw->wantToWrite++;
    315     while( rw->haveWriter || rw->readCount )
    316         tr_condWait( rw->writeCond, rw->lock );
    317     rw->wantToWrite--;
    318     rw->haveWriter = TRUE;
    319     tr_lockUnlock( rw->lock );
    320 }
    321 
    322 int
    323 tr_rwWriterTrylock( tr_rwlock * rw )
    324 {
    325     int ret = FALSE;
    326     tr_lockLock( rw->lock );
    327     if( !rw->haveWriter && !rw->readCount )
    328         ret = rw->haveWriter = TRUE;
    329     tr_lockUnlock( rw->lock );
    330     return ret;
    331 }
    332 void
    333 tr_rwWriterUnlock( tr_rwlock * rw )
    334 {
    335     tr_lockLock( rw->lock );
    336     rw->haveWriter = FALSE;
    337     tr_rwSignal( rw );
    338     tr_lockUnlock( rw->lock );
    339 }
    340 
    341 void
    342 tr_rwFree( tr_rwlock * rw )
    343 {
    344     tr_condFree( rw->writeCond );
    345     tr_condFree( rw->readCond );
    346     tr_lockFree( rw->lock );
    347     tr_free( rw );
    348 }
    349 
    350 /***
    351241****  COND
    352242***/
  • branches/encryption/libtransmission/platform.h

    r3025 r3072  
    4949void         tr_condWait      ( tr_cond *, tr_lock * );
    5050
    51 /***
    52 **** RW lock:
    53 **** The lock can be had by one writer or any number of readers.
    54 ***/
    55 
    56 typedef struct tr_rwlock tr_rwlock;
    57 
    58 tr_rwlock*    tr_rwNew           ( void );
    59 void          tr_rwFree          ( tr_rwlock * );
    60 void          tr_rwReaderLock    ( tr_rwlock * );
    61 int           tr_rwReaderTrylock ( tr_rwlock * );
    62 void          tr_rwReaderUnlock  ( tr_rwlock * );
    63 void          tr_rwWriterLock    ( tr_rwlock * );
    64 int           tr_rwWriterTrylock ( tr_rwlock * );
    65 void          tr_rwWriterUnlock  ( tr_rwlock * );
    66 
    67 
    6851struct in_addr; /* forward declaration to calm gcc down */
    6952int
  • branches/encryption/libtransmission/torrent.c

    r3057 r3072  
    8383
    8484void
    85 tr_torrentReaderLock( const tr_torrent * tor )
    86 {
    87     tr_rwReaderLock ( (tr_rwlock*)tor->lock );
    88 }
    89 
    90 void
    91 tr_torrentReaderUnlock( const tr_torrent * tor )
    92 {
    93     tr_rwReaderUnlock ( (tr_rwlock*)tor->lock );
    94 }
    95 
    96 void
    97 tr_torrentWriterLock( tr_torrent * tor )
    98 {
    99     tr_rwWriterLock ( tor->lock );
    100 }
    101 
    102 void
    103 tr_torrentWriterUnlock( tr_torrent * tor )
    104 {
    105     tr_rwWriterUnlock ( tor->lock );
     85tr_torrentLock( const tr_torrent * tor )
     86{
     87    tr_lockLock ( (tr_lock*)tor->lock );
     88}
     89
     90void
     91tr_torrentUnlock( const tr_torrent * tor )
     92{
     93    tr_lockUnlock ( (tr_lock*)tor->lock );
    10694}
    10795
     
    359347    tr_torrentInitFilePieces( tor );
    360348
    361     tor->lock = tr_rwNew( );
     349    tor->lock = tr_lockNew( );
    362350
    363351    tor->upload         = tr_rcInit();
     
    679667tr_torrentChangeMyPort( tr_torrent * tor, int port )
    680668{
    681     tr_torrentWriterLock( tor );
     669    tr_torrentLock( tor );
    682670
    683671    tor->publicPort = port;
     
    686674        tr_trackerChangeMyPort( tor->tracker );
    687675
    688     tr_torrentWriterUnlock( tor );
     676    tr_torrentUnlock( tor );
    689677}
    690678
     
    697685void tr_torrentDisablePex( tr_torrent * tor, int disable )
    698686{
    699     tr_torrentWriterLock( tor );
     687    tr_torrentLock( tor );
    700688
    701689    if( ! ( TR_FLAG_PRIVATE & tor->info.flags ) )
     
    710698    }
    711699
    712     tr_torrentWriterUnlock( tor );
     700    tr_torrentUnlock( tor );
    713701}
    714702
     
    717705    int ret;
    718706
    719     tr_torrentWriterLock( tor );
     707    tr_torrentLock( tor );
    720708    if (( ret = tor->hasChangedState == status ))
    721709        tor->hasChangedState = -1;
    722     tr_torrentWriterUnlock( tor );
     710    tr_torrentUnlock( tor );
    723711
    724712    return ret;
     
    758746    struct tr_tracker * tc;
    759747
    760     tr_torrentReaderLock( tor );
     748    tr_torrentLock( tor );
    761749
    762750    tor->statCur = ( tor->statCur + 1 ) % 2;
     
    833821      : TR_RATIO_NA;
    834822   
    835     tr_torrentReaderUnlock( tor );
     823    tr_torrentUnlock( tor );
    836824
    837825    return s;
     
    952940    int i;
    953941    float interval;
    954     tr_torrentReaderLock( tor );
     942    tr_torrentLock( tor );
    955943
    956944    interval = (float)tor->info.pieceCount / (float)size;
     
    961949    }
    962950
    963     tr_torrentReaderUnlock( tor );
     951    tr_torrentUnlock( tor );
    964952}
    965953
     
    967955tr_torrentResetTransferStats( tr_torrent * tor )
    968956{
    969     tr_torrentWriterLock( tor );
     957    tr_torrentLock( tor );
    970958
    971959    tor->downloadedPrev += tor->downloadedCur;
     
    976964    tor->corruptCur      = 0;
    977965
    978     tr_torrentWriterUnlock( tor );
     966    tr_torrentUnlock( tor );
    979967}
    980968
     
    983971tr_torrentSetHasPiece( tr_torrent * tor, int pieceIndex, int has )
    984972{
    985     tr_torrentWriterLock( tor );
     973    tr_torrentLock( tor );
    986974
    987975    if( has )
     
    990978        tr_cpPieceRem( tor->completion, pieceIndex );
    991979
    992     tr_torrentWriterUnlock( tor );
     980    tr_torrentUnlock( tor );
    993981}
    994982
     
    10301018    tr_sharedLock( h->shared );
    10311019
    1032     tr_rwFree( tor->lock );
     1020    tr_lockFree( tor->lock );
    10331021    tr_cpClose( tor->completion );
    10341022
     
    11271115    cp_status_t cpStatus;
    11281116
    1129     tr_torrentWriterLock( tor );
     1117    tr_torrentLock( tor );
    11301118
    11311119    cpStatus = tr_cpGetStatus( tor->completion );
     
    11401128        saveFastResumeSoon( tor );
    11411129    }
    1142     tr_torrentWriterUnlock( tor );
     1130    tr_torrentUnlock( tor );
    11431131}
    11441132
     
    11551143    tr_file_t * file;
    11561144
    1157     tr_torrentWriterLock( tor );
     1145    tr_torrentLock( tor );
    11581146
    11591147    assert( tor != NULL );
     
    11721160    saveFastResumeSoon( tor );
    11731161
    1174     tr_torrentWriterUnlock( tor );
     1162    tr_torrentUnlock( tor );
    11751163}
    11761164
     
    11911179    tr_priority_t ret;
    11921180
    1193     tr_torrentReaderLock( tor );
     1181    tr_torrentLock( tor );
    11941182    assert( tor != NULL );
    11951183    assert( 0<=file && file<tor->info.fileCount );
    11961184    ret = tor->info.files[file].priority;
    1197     tr_torrentReaderUnlock( tor );
     1185    tr_torrentUnlock( tor );
    11981186
    11991187    return ret;
     
    12071195    tr_priority_t * p;
    12081196
    1209     tr_torrentReaderLock( tor );
     1197    tr_torrentLock( tor );
    12101198    p = tr_new0( tr_priority_t, tor->info.fileCount );
    12111199    for( i=0; i<tor->info.fileCount; ++i )
    12121200        p[i] = tor->info.files[i].priority;
    1213     tr_torrentReaderUnlock( tor );
     1201    tr_torrentUnlock( tor );
    12141202
    12151203    return p;
     
    12251213{
    12261214    int doDownload;
    1227     tr_torrentReaderLock( tor );
     1215    tr_torrentLock( tor );
    12281216
    12291217    assert( 0<=file && file<tor->info.fileCount );
    12301218    doDownload = !tor->info.files[file].dnd;
    12311219
    1232     tr_torrentReaderUnlock( tor );
     1220    tr_torrentUnlock( tor );
    12331221    return doDownload != 0;
    12341222}
     
    12451233    int i;
    12461234
    1247     tr_torrentWriterLock( tor );
     1235    tr_torrentLock( tor );
    12481236
    12491237    file = &tor->info.files[fileIndex];
     
    12861274    saveFastResumeSoon( tor );
    12871275
    1288     tr_torrentWriterUnlock( tor );
     1276    tr_torrentUnlock( tor );
    12891277}
    12901278
  • branches/encryption/libtransmission/transmission.c

    r3050 r3072  
    222222    for( tor = h->torrentList; tor; tor = tor->next )
    223223    {
    224         tr_torrentReaderLock( tor );
     224        tr_torrentLock( tor );
    225225        if( tor->cpStatus == TR_CP_INCOMPLETE )
    226226            *dl += tr_rcRate( tor->download );
    227227        *ul += tr_rcRate( tor->upload );
    228         tr_torrentReaderUnlock( tor );
     228        tr_torrentUnlock( tor );
    229229    }
    230230    tr_sharedUnlock( h->shared );
Note: See TracChangeset for help on using the changeset viewer.