Ignore:
Timestamp:
Apr 26, 2009, 12:51:51 AM (13 years ago)
Author:
charles
Message:

(trunk libT) need feedback from Mac users on this change. On Linux, it gets rid of the inactive-memory-grows-during-torrent-verification behavior that's often reported as a bug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r8198 r8291  
    203203
    204204FILE*
    205 tr_open_file_for_reading( const char * filename, tr_bool sequential )
     205tr_open_file_for_scanning( const char * filename )
    206206{
    207207    int fd;
     
    229229
    230230#ifdef HAVE_POSIX_FADVISE
    231     posix_fadvise( fd, 0, 0, sequential ? POSIX_FADV_SEQUENTIAL : POSIX_FADV_RANDOM );
     231    posix_fadvise( fd, 0, 0, POSIX_FADV_SEQUENTIAL );
    232232#endif
    233233
    234234    return fdopen( fd, "r" );
     235}
     236
     237static void
     238flush_before_closing( int fd )
     239{
     240#if defined(HAVE_POSIX_FADVISE)
     241    posix_fadvise( fd, 0, 0, POSIX_FADV_DONTNEED );
     242#elif defined(SYS_DARWIN)
     243    fcntl( fd, F_NOCACHE, 1 );
     244#endif
     245}
     246
     247void
     248tr_close_file( FILE * fp )
     249{
     250    flush_before_closing( fileno( fp ) );
     251    fclose( fp );
    235252}
    236253
     
    328345    assert( fileIsOpen( o ) );
    329346
     347    flush_before_closing( o->fd );
    330348    close( o->fd );
    331349    o->fd = -1;
Note: See TracChangeset for help on using the changeset viewer.