Changeset 12397


Ignore:
Timestamp:
Apr 28, 2011, 6:40:46 PM (10 years ago)
Author:
jordan
Message:

(trunk libT) tr_torrentGetFileMTime(): if the file being looked at is aleady open in fdlimit's file cache, use that cached handle instead of deriving our own.

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r12373 r12397  
    562562}
    563563
     564#ifdef SYS_DARWIN
     565 #define TR_STAT_MTIME(sb) ((sb).st_mtimespec.tv_sec)
     566#else
     567 #define TR_STAT_MTIME(sb) ((sb).st_mtime)
     568#endif
     569
     570bool
     571tr_fdFileGetCachedMTime( tr_session * s, int torrent_id, tr_file_index_t i, time_t * mtime )
     572{
     573    bool success;
     574    struct stat sb;
     575    struct tr_cached_file * o = fileset_lookup( get_fileset( s ), torrent_id, i );
     576
     577    if(( success = ( o != NULL ) && !fstat( o->fd, &sb )))
     578        *mtime = TR_STAT_MTIME( sb );
     579
     580    return success;
     581}
     582
    564583void
    565584tr_fdTorrentClose( tr_session * session, int torrent_id )
  • trunk/libtransmission/fdlimit.h

    r12204 r12397  
    8282                        bool                  doWrite );
    8383
     84bool tr_fdFileGetCachedMTime( tr_session       * session,
     85                              int                torrent_id,
     86                              tr_file_index_t    file_num,
     87                              time_t           * mtime );
     88
     89
    8490/**
    8591 * Closes a file that's being held by our file repository.
  • trunk/libtransmission/torrent.c

    r12296 r12397  
    23732373{
    23742374    time_t mtime = 0;
    2375     tr_torrentFindFile2( tor, i, NULL, NULL, &mtime );
     2375    if( !tr_fdFileGetCachedMTime( tor->session, tor->uniqueId, i, &mtime ) )
     2376        tr_torrentFindFile2( tor, i, NULL, NULL, &mtime );
    23762377    return mtime;
    23772378}
     
    29532954***/
    29542955
     2956#ifdef SYS_DARWIN
     2957 #define TR_STAT_MTIME(sb) ((sb).st_mtimespec.tv_sec)
     2958#else
     2959 #define TR_STAT_MTIME(sb) ((sb).st_mtime)
     2960#endif
     2961
     2962
    29552963static bool
    29562964fileExists( const char * filename, time_t * mtime )
     
    29602968
    29612969    if( ok && ( mtime != NULL ) )
    2962     {
    2963 #ifdef SYS_DARWIN
    2964         *mtime = sb.st_mtimespec.tv_sec;
    2965 #else
    2966         *mtime = sb.st_mtime;
    2967 #endif
    2968     }
     2970        *mtime = TR_STAT_MTIME( sb );
    29692971
    29702972    return ok;
Note: See TracChangeset for help on using the changeset viewer.