]> granicus.if.org Git - transmission/commitdiff
(libT) housekeeping: tr_torrent.handle --> tr_torrent.session
authorCharles Kerr <charles@transmissionbt.com>
Thu, 2 Oct 2008 15:53:33 +0000 (15:53 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Thu, 2 Oct 2008 15:53:33 +0000 (15:53 +0000)
libtransmission/fastresume.c
libtransmission/inout.c
libtransmission/peer-mgr.c
libtransmission/peer-msgs.c
libtransmission/resume.c
libtransmission/torrent.c
libtransmission/torrent.h
libtransmission/tracker.c
libtransmission/webseed.c

index 0bb298830340ba6841e6b6e2257002f8e4941c72..b70c6c9b1566cf801c6f788fa1b02fcf0c8cfbf4 100644 (file)
@@ -615,7 +615,7 @@ parsePeers( tr_torrent *    tor,
         {
             tr_pex pex;
             readBytes( &pex, &buf, sizeof( tr_pex ) );
-            tr_peerMgrAddPex( tor->handle->peerMgr, tor->info.hash,
+            tr_peerMgrAddPex( tor->session->peerMgr, tor->info.hash,
                               TR_PEER_FROM_CACHE,
                               &pex );
         }
@@ -713,13 +713,13 @@ loadResumeFile( const tr_torrent * tor,
 {
     uint8_t *    ret = NULL;
     char         path[MAX_PATH_LENGTH];
-    const char * cacheDir = tr_getResumeDir( tor->handle );
+    const char * cacheDir = tr_getResumeDir( tor->session );
     const char * hash = tor->info.hashString;
 
-    if( !ret && tor->handle->tag )
+    if( !ret && tor->session->tag )
     {
         char base[1024];
-        tr_snprintf( base, sizeof( base ), "%s-%s", hash, tor->handle->tag );
+        tr_snprintf( base, sizeof( base ), "%s-%s", hash, tor->session->tag );
         tr_buildPath( path, sizeof( path ), cacheDir, base, NULL );
         ret = tr_loadFile( path, len );
     }
@@ -776,13 +776,13 @@ void
 tr_fastResumeRemove( const tr_torrent * tor )
 {
     char         path[MAX_PATH_LENGTH];
-    const char * cacheDir = tr_getResumeDir( tor->handle );
+    const char * cacheDir = tr_getResumeDir( tor->session );
     const char * hash = tor->info.hashString;
 
-    if( tor->handle->tag )
+    if( tor->session->tag )
     {
         char base[1024];
-        tr_snprintf( base, sizeof( base ), "%s-%s", hash, tor->handle->tag );
+        tr_snprintf( base, sizeof( base ), "%s-%s", hash, tor->session->tag );
         tr_buildPath( path, sizeof( path ), cacheDir, base, NULL );
         unlink( path );
     }
index 065f2895fc350836bacbec03934da8da0c7cbc8b..3cd670c41b295c1a2e76dfb1ff37437269157d71 100644 (file)
@@ -84,7 +84,7 @@ readOrWriteBytes( const tr_torrent * tor,
         err = TR_OK;
 
     if( ( err == TR_OK ) && ( !fileExists ) && ( ioMode == TR_IO_WRITE ) )
-        tr_statsFileCreated( tor->handle );
+        tr_statsFileCreated( tor->session );
 
     if( fd >= 0 )
         tr_fdFileReturn( fd );
index 70ef80675b170a4259550550f5ee8b1dbd3ebc29..995078072c0a67a4a450557f963a4bb62b5bdca7 100644 (file)
@@ -889,7 +889,7 @@ peerCallbackFunc( void * vpeer,
             tr_torrent * tor = t->tor;
             tor->activityDate = now;
             tor->uploadedCur += e->length;
-            tr_statsAddUploaded( tor->handle, e->length );
+            tr_statsAddUploaded( tor->session, e->length );
             if( peer )
             {
                 struct peer_atom * atom = getExistingAtom( t,
@@ -912,7 +912,7 @@ peerCallbackFunc( void * vpeer,
              * into the jurisdiction of the tracker." */
             if( peer )
                 tor->downloadedCur += e->length;
-            tr_statsAddDownloaded( tor->handle, e->length );
+            tr_statsAddDownloaded( tor->session, e->length );
             if( peer )
             {
                 struct peer_atom * atom = getExistingAtom( t,
@@ -971,7 +971,7 @@ peerCallbackFunc( void * vpeer,
 
                 tr_torrentSetHasPiece( tor, p, !err );
                 tr_torrentSetPieceChecked( tor, p, TRUE );
-                tr_peerMgrSetBlame( tor->handle->peerMgr, tor->info.hash, p,
+                tr_peerMgrSetBlame( tor->session->peerMgr, tor->info.hash, p,
                                     !err );
 
                 if( err )
index de15b71c372d0f79eedcf2a8d4777234a8e6c230..f930d4f09b7ac61e6374f6e44a1e64206df47bd2 100644 (file)
@@ -2092,7 +2092,7 @@ tr_peerMsgsNew( struct tr_torrent * torrent,
     m = tr_new0( tr_peermsgs, 1 );
     m->publisher = tr_publisherNew( );
     m->info = info;
-    m->session = torrent->handle;
+    m->session = torrent->session;
     m->torrent = torrent;
     m->io = info->io;
     m->info->clientIsChoked = 1;
index 7717fdf02449ed226f0edcfbb25efbcfdb99bc71..119a615469f23e2bb88d5a8b90b0a868777ad27f 100644 (file)
@@ -51,7 +51,7 @@ static char*
 getResumeFilename( const tr_torrent * tor )
 {
     return tr_strdup_printf( "%s%c%s.%16.16s.resume",
-                             tr_getResumeDir( tor->handle ),
+                             tr_getResumeDir( tor->session ),
                              TR_PATH_DELIMITER,
                              tor->info.name,
                              tor->info.hashString );
@@ -66,7 +66,7 @@ savePeers( tr_benc *          dict,
            const tr_torrent * tor )
 {
     tr_pex *  pex = NULL;
-    const int count = tr_peerMgrGetPeers( tor->handle->peerMgr,
+    const int count = tr_peerMgrGetPeers( tor->session->peerMgr,
                                           tor->info.hash, &pex );
 
     if( count > 0 )
@@ -90,7 +90,7 @@ loadPeers( tr_benc *    dict,
         {
             tr_pex pex;
             memcpy( &pex, str + ( i * sizeof( tr_pex ) ), sizeof( tr_pex ) );
-            tr_peerMgrAddPex( tor->handle->peerMgr,
+            tr_peerMgrAddPex( tor->session->peerMgr,
                               tor->info.hash, TR_PEER_FROM_CACHE, &pex );
         }
         tr_tordbg( tor, "Loaded %d peers from resume file", count );
index a238c1003c396e003b9ac01441cd65955f4918b4..0513d6d5b2a253be6730fca2200ab7fa8442c3e8 100644 (file)
@@ -126,13 +126,13 @@ tr_torrentFindFromObfuscatedHash( tr_handle *     handle,
 void
 tr_torrentLock( const tr_torrent * tor )
 {
-    tr_globalLock( tor->handle );
+    tr_globalLock( tor->session );
 }
 
 void
 tr_torrentUnlock( const tr_torrent * tor )
 {
-    tr_globalUnlock( tor->handle );
+    tr_globalUnlock( tor->session );
 }
 
 /***
@@ -222,7 +222,7 @@ onTrackerResponse( void * tracker UNUSED,
             {
                 if( event->allAreSeeds )
                     pex[i].flags |= ADDED_F_SEED_FLAG;
-                tr_peerMgrAddPex( tor->handle->peerMgr, tor->info.hash,
+                tr_peerMgrAddPex( tor->session->peerMgr, tor->info.hash,
                                   TR_PEER_FROM_TRACKER, pex + i );
             }
 
@@ -461,7 +461,7 @@ torrentRealInit( tr_handle *     h,
 
     tr_globalLock( h );
 
-    tor->handle   = h;
+    tor->session   = h;
     tor->uniqueId = nextUniqueId++;
 
     randomizeTiers( info );
@@ -537,9 +537,9 @@ torrentRealInit( tr_handle *     h,
     if( !( loaded & TR_FR_SPEEDLIMIT ) )
     {
         tr_torrentSetSpeedLimit( tor, TR_UP,
-                                tr_sessionGetSpeedLimit( tor->handle, TR_UP ) );
+                                tr_sessionGetSpeedLimit( tor->session, TR_UP ) );
         tr_torrentSetSpeedLimit( tor, TR_DOWN,
-                                tr_sessionGetSpeedLimit( tor->handle,
+                                tr_sessionGetSpeedLimit( tor->session,
                                                          TR_DOWN ) );
     }
 
@@ -573,7 +573,7 @@ torrentRealInit( tr_handle *     h,
         {
             const char * filename = tor->info.torrent;
             tr_bencSaveFile( filename, val );
-            tr_sessionSetTorrentFile( tor->handle, tor->info.hashString,
+            tr_sessionSetTorrentFile( tor->session, tor->info.hashString,
                                       filename );
         }
     }
@@ -680,7 +680,7 @@ int
 tr_torrentAllowsPex( const tr_torrent * tor )
 {
     return tor
-           && tor->handle->isPexEnabled
+           && tor->session->isPexEnabled
            && !tr_torrentIsPrivate( tor );
 }
 
@@ -696,7 +696,7 @@ tr_torrentManualUpdateImpl( void * vtor )
 void
 tr_torrentManualUpdate( tr_torrent * tor )
 {
-    tr_runInEventThread( tor->handle, tr_torrentManualUpdateImpl, tor );
+    tr_runInEventThread( tor->session, tr_torrentManualUpdateImpl, tor );
 }
 
 int
@@ -769,7 +769,7 @@ tr_torrentStat( tr_torrent * tor )
     tr_trackerGetCounts( tc, &s->timesCompleted,
                          &s->leechers,
                          &s->seeders );
-    tr_peerMgrTorrentStats( tor->handle->peerMgr,
+    tr_peerMgrTorrentStats( tor->session->peerMgr,
                             tor->info.hash,
                             &s->peersKnown,
                             &s->peersConnected,
@@ -821,7 +821,7 @@ tr_torrentStat( tr_torrent * tor )
     {
         tr_piece_index_t i;
         tr_bitfield *    peerPieces = tr_peerMgrGetAvailable(
-            tor->handle->peerMgr,
+            tor->session->peerMgr,
             tor->info.
             hash );
         s->desiredAvailable = 0;
@@ -941,7 +941,7 @@ tr_torrentFilesFree( tr_file_stat *            files,
 float*
 tr_torrentWebSpeeds( const tr_torrent * tor )
 {
-    return tor ? tr_peerMgrWebSpeeds( tor->handle->peerMgr, tor->info.hash )
+    return tor ? tr_peerMgrWebSpeeds( tor->session->peerMgr, tor->info.hash )
            : NULL;
 }
 
@@ -952,7 +952,7 @@ tr_torrentPeers( const tr_torrent * tor,
     tr_peer_stat * ret = NULL;
 
     if( tor )
-        ret = tr_peerMgrPeerStats( tor->handle->peerMgr,
+        ret = tr_peerMgrPeerStats( tor->session->peerMgr,
                                    tor->info.hash, peerCount );
 
     return ret;
@@ -970,7 +970,7 @@ tr_torrentAvailability( const tr_torrent * tor,
                         int8_t *           tab,
                         int                size )
 {
-    tr_peerMgrTorrentAvailability( tor->handle->peerMgr,
+    tr_peerMgrTorrentAvailability( tor->session->peerMgr,
                                    tor->info.hash,
                                    tab, size );
 }
@@ -1026,7 +1026,7 @@ static void
 freeTorrent( tr_torrent * tor )
 {
     tr_torrent * t;
-    tr_handle *  h = tor->handle;
+    tr_handle *  h = tor->session;
     tr_info *    inf = &tor->info;
 
     assert( tor );
@@ -1077,7 +1077,7 @@ checkAndStartImpl( void * vtor )
 {
     tr_torrent * tor = vtor;
 
-    tr_globalLock( tor->handle );
+    tr_globalLock( tor->session );
 
     tor->isRunning  = 1;
     *tor->errorString = '\0';
@@ -1086,22 +1086,22 @@ checkAndStartImpl( void * vtor )
     tr_torrentSaveResume( tor );
     tor->startDate = time( NULL );
     tr_trackerStart( tor->tracker );
-    tr_peerMgrStartTorrent( tor->handle->peerMgr, tor->info.hash );
+    tr_peerMgrStartTorrent( tor->session->peerMgr, tor->info.hash );
 
-    tr_globalUnlock( tor->handle );
+    tr_globalUnlock( tor->session );
 }
 
 static void
 checkAndStartCB( tr_torrent * tor )
 {
-    tr_runInEventThread( tor->handle, checkAndStartImpl, tor );
+    tr_runInEventThread( tor->session, checkAndStartImpl, tor );
 }
 
 static void
 torrentStart( tr_torrent * tor,
               int          reloadProgress )
 {
-    tr_globalLock( tor->handle );
+    tr_globalLock( tor->session );
 
     if( !tor->isRunning )
     {
@@ -1111,7 +1111,7 @@ torrentStart( tr_torrent * tor,
         tr_verifyAdd( tor, checkAndStartCB );
     }
 
-    tr_globalUnlock( tor->handle );
+    tr_globalUnlock( tor->session );
 }
 
 void
@@ -1130,7 +1130,7 @@ torrentRecheckDoneImpl( void * vtor )
 static void
 torrentRecheckDoneCB( tr_torrent * tor )
 {
-    tr_runInEventThread( tor->handle, torrentRecheckDoneImpl, tor );
+    tr_runInEventThread( tor->session, torrentRecheckDoneImpl, tor );
 }
 
 void
@@ -1138,12 +1138,12 @@ tr_torrentVerify( tr_torrent * tor )
 {
     tr_verifyRemove( tor );
 
-    tr_globalLock( tor->handle );
+    tr_globalLock( tor->session );
 
     tr_torrentUncheck( tor );
     tr_verifyAdd( tor, torrentRecheckDoneCB );
 
-    tr_globalUnlock( tor->handle );
+    tr_globalUnlock( tor->session );
 }
 
 static void
@@ -1154,7 +1154,7 @@ stopTorrent( void * vtor )
     tr_torrent *    tor = vtor;
 
     tr_verifyRemove( tor );
-    tr_peerMgrStopTorrent( tor->handle->peerMgr, tor->info.hash );
+    tr_peerMgrStopTorrent( tor->session->peerMgr, tor->info.hash );
     tr_trackerStop( tor->tracker );
 
     for( i = 0; i < tor->info.fileCount; ++i )
@@ -1172,14 +1172,14 @@ tr_torrentStop( tr_torrent * tor )
 {
     if( tor )
     {
-        tr_globalLock( tor->handle );
+        tr_globalLock( tor->session );
 
         tor->isRunning = 0;
         if( !tor->isDeleting )
             tr_torrentSaveResume( tor );
-        tr_runInEventThread( tor->handle, stopTorrent, tor );
+        tr_runInEventThread( tor->session, stopTorrent, tor );
 
-        tr_globalUnlock( tor->handle );
+        tr_globalUnlock( tor->session );
     }
 }
 
@@ -1193,7 +1193,7 @@ closeTorrent( void * vtor )
     stopTorrent( tor );
     if( tor->isDeleting )
     {
-        tr_metainfoRemoveSaved( tor->handle, &tor->info );
+        tr_metainfoRemoveSaved( tor->session, &tor->info );
         tr_torrentRemoveResume( tor );
     }
     freeTorrent( tor );
@@ -1204,7 +1204,7 @@ tr_torrentFree( tr_torrent * tor )
 {
     if( tor )
     {
-        tr_handle * handle = tor->handle;
+        tr_handle * handle = tor->session;
         tr_globalLock( handle );
 
         tr_torrentClearStatusCallback( tor );
@@ -1702,7 +1702,7 @@ tr_torrentSetAnnounceList( tr_torrent *            tor,
 
         /* try to parse it back again, to make sure it's good */
         memset( &tmpInfo, 0, sizeof( tr_info ) );
-        if( !tr_metainfoParse( tor->handle, &tmpInfo, &metainfo ) )
+        if( !tr_metainfoParse( tor->session, &tmpInfo, &metainfo ) )
         {
             /* if it's good, save it and use it */
             tr_metainfoFree( &tor->info );
index bb72f486475c342e3faa9565be30e5182eefe32f..e7a4e111150edc11b93579933aeeb5bd7cfc4df0 100644 (file)
@@ -41,31 +41,28 @@ void        tr_torrentSetHasPiece( tr_torrent *     tor,
                                    tr_piece_index_t pieceIndex,
                                    int              has );
 
-void        tr_torrentLock( const tr_torrent * );
+void        tr_torrentLock( const tr_torrent * session );
 
-void        tr_torrentUnlock( const tr_torrent * );
+void        tr_torrentUnlock( const tr_torrent * session );
 
-int         tr_torrentIsSeed( const tr_torrent * );
+int         tr_torrentIsSeed( const tr_torrent * session );
 
-void        tr_torrentChangeMyPort( tr_torrent * );
+void        tr_torrentChangeMyPort( tr_torrent * session );
 
-int         tr_torrentExists( const tr_handle *,
-                              const uint8_t * );
+int         tr_torrentExists( const tr_session * session,
+                              const uint8_t    * hash );
 
-tr_torrent* tr_torrentFindFromId(                     tr_handle *,
-                                                  int id );
+tr_torrent* tr_torrentFindFromId( tr_session * session,
+                                  int          id );
 
-tr_torrent* tr_torrentFindFromHash(                               tr_handle *,
-                                                            const uint8_t * );
+tr_torrent* tr_torrentFindFromHash( tr_session *    session,
+                                    const uint8_t * hash );
 
-tr_torrent* tr_torrentFindFromHashString(
-          tr_handle *,
-    const char * );
+tr_torrent* tr_torrentFindFromHashString( tr_session * session,
+                                          const char * hashString );
 
-tr_torrent* tr_torrentFindFromObfuscatedHash(
-    tr_handle *,
-    const
-    uint8_t* );
+tr_torrent* tr_torrentFindFromObfuscatedHash( tr_session    * session,
+                                              const uint8_t * hash );
 
 int         tr_torrentAllowsPex( const tr_torrent * );
 
@@ -153,7 +150,7 @@ tr_verify_state;
 
 struct tr_torrent
 {
-    tr_handle *              handle;
+    tr_session *             session;
     tr_info                  info;
 
     int                      uploadLimit;
index 77b97a9f765838def9f694d8a54f16e49e447f58..52af47b5bc904417ad2a2fc08a56c204dea3e77d 100644 (file)
@@ -913,11 +913,11 @@ tr_trackerNew( const tr_torrent * torrent )
     const tr_info * info = &torrent->info;
     tr_tracker *    t;
 
-    ensureGlobalsExist( torrent->handle );
+    ensureGlobalsExist( torrent->session );
 
     t = tr_new0( tr_tracker, 1 );
     t->publisher = tr_publisherNew( );
-    t->session                  = torrent->handle;
+    t->session                  = torrent->session;
     t->scrapeIntervalSec        = DEFAULT_SCRAPE_INTERVAL_SEC;
     t->retryScrapeIntervalSec   = FIRST_SCRAPE_RETRY_INTERVAL_SEC;
     t->retryAnnounceIntervalSec = FIRST_ANNOUNCE_RETRY_INTERVAL_SEC;
index 19e67accb819691c6ed6d24623377ed8147da7f8..51e010937f7678b7301073de8de09237177439b2 100644 (file)
@@ -300,7 +300,7 @@ requestNextChunk( tr_webseed * w )
   left, and we're asking for %lu this time\n", range, (unsigned
   long)tr_torPieceCountBytes(w->torrent,piece), (unsigned long)have, (unsigned
   long)left, (unsigned long)thisPass );*/
-    tr_webRun( w->torrent->handle, url, range, webResponseFunc, w );
+    tr_webRun( w->torrent->session, url, range, webResponseFunc, w );
     tr_free( range );
     tr_free( url );
 }