Changeset 11544


Ignore:
Timestamp:
Dec 17, 2010, 3:36:31 PM (11 years ago)
Author:
charles
Message:

(trunk libT) #3531 "Pausing 500 torrents uses 650 MB of memory" -- on OS X, when saving a benc/json file, send a hint to the OS to not cache the file.

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode.c

    r11445 r11544  
    16641664    tmp = tr_strdup_printf( "%s.tmp.XXXXXX", filename );
    16651665    fd = tr_mkstemp( tmp );
     1666    tr_set_file_for_single_pass( fd );
    16661667    if( fd >= 0 )
    16671668    {
  • trunk/libtransmission/fdlimit.c

    r11531 r11544  
    259259}
    260260
    261 int
    262 tr_open_file_for_writing( const char * filename )
    263 {
    264     int flags = O_WRONLY | O_CREAT;
    265 #ifdef O_BINARY
    266     flags |= O_BINARY;
    267 #endif
    268 #ifdef O_LARGEFILE
    269     flags |= O_LARGEFILE;
    270 #endif
    271     return open( filename, flags, 0666 );
    272 }
    273 
    274 int
    275 tr_open_file_for_scanning( const char * filename )
    276 {
    277     int fd;
    278     int flags;
    279 
    280     /* build the flags */
    281     flags = O_RDONLY;
    282 #ifdef O_SEQUENTIAL
    283     flags |= O_SEQUENTIAL;
    284 #endif
    285 #ifdef O_BINARY
    286     flags |= O_BINARY;
    287 #endif
    288 #ifdef O_LARGEFILE
    289     flags |= O_LARGEFILE;
    290 #endif
    291 
    292     /* open the file */
    293     fd = open( filename, flags, 0666 );
     261void
     262tr_set_file_for_single_pass( int fd )
     263{
    294264    if( fd >= 0 )
    295265    {
     
    301271#endif
    302272#ifdef SYS_DARWIN
     273        fcntl( fd, F_RDAHEAD, 1 );
    303274        fcntl( fd, F_NOCACHE, 1 );
    304         fcntl( fd, F_RDAHEAD, 1 );
    305275#endif
    306276        errno = err;
    307277    }
    308 
     278}
     279
     280int
     281tr_open_file_for_writing( const char * filename )
     282{
     283    int fd;
     284    int flags = O_WRONLY | O_CREAT;
     285#ifdef O_BINARY
     286    flags |= O_BINARY;
     287#endif
     288#ifdef O_LARGEFILE
     289    flags |= O_LARGEFILE;
     290#endif
     291    fd = open( filename, flags, 0666 );
     292    tr_set_file_for_single_pass( fd );
     293    return fd;
     294}
     295
     296int
     297tr_open_file_for_scanning( const char * filename )
     298{
     299    int fd;
     300    int flags;
     301
     302    /* build the flags */
     303    flags = O_RDONLY;
     304#ifdef O_SEQUENTIAL
     305    flags |= O_SEQUENTIAL;
     306#endif
     307#ifdef O_BINARY
     308    flags |= O_BINARY;
     309#endif
     310#ifdef O_LARGEFILE
     311    flags |= O_LARGEFILE;
     312#endif
     313
     314    /* open the file */
     315    fd = open( filename, flags, 0666 );
     316    tr_set_file_for_single_pass( fd );
    309317    return fd;
    310318}
  • trunk/libtransmission/fdlimit.h

    r10904 r11544  
    3232****
    3333***/
     34
     35void tr_set_file_for_single_pass( int fd );
    3436
    3537int tr_open_file_for_scanning( const char * filename );
Note: See TracChangeset for help on using the changeset viewer.