Changeset 10798
- Timestamp:
- Jun 19, 2010, 2:25:11 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/daemon/remote.c
r10783 r10798 208 208 { 'd', "downlimit", "Set the max download speed in KiB/s for the current torrent(s) or globally", "d", 1, "<speed>" }, 209 209 { 'D', "no-downlimit", "Disable max download speed for the current torrent(s) or globally", "D", 0, NULL }, 210 { 'e', "cache", "Set the maximum size of the session's memory cache (in MiB)", "e", 1, "<size>" }, 210 211 { 910, "encryption-required", "Encrypt all peer connections", "er", 0, NULL }, 211 212 { 911, "encryption-preferred", "Prefer encrypted peer connections", "ep", 0, NULL }, … … 323 324 case 'c': /* incomplete-dir */ 324 325 case 'C': /* no-incomplete-dir */ 326 case 'e': /* cache */ 325 327 case 'm': /* portmap */ 326 328 case 'M': /* "no-portmap */ … … 1330 1332 if( ( tr_bencDictFindDict( top, "arguments", &args ) ) ) 1331 1333 { 1334 double d; 1332 1335 const char * str; 1333 1336 int64_t i; 1334 1337 tr_bool boolVal; 1338 char buf[64]; 1335 1339 1336 1340 printf( "VERSION\n" ); … … 1360 1364 if( tr_bencDictFindStr( args, TR_PREFS_KEY_ENCRYPTION, &str ) ) 1361 1365 printf( " Encryption: %s\n", str ); 1366 if( tr_bencDictFindReal( args, TR_PREFS_KEY_MAX_CACHE_SIZE_MiB, &d ) ) 1367 printf( " Maximum memory cache size: %s\n", strlsize( buf, d*MiB, sizeof( buf ) ) ); 1362 1368 printf( "\n" ); 1363 1369 … … 1817 1823 case 'C': tr_bencDictAddBool( args, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, FALSE ); 1818 1824 break; 1825 case 'e': tr_bencDictAddReal( args, TR_PREFS_KEY_MAX_CACHE_SIZE_MiB, atof(optarg) ); 1826 break; 1819 1827 case 910: tr_bencDictAddStr( args, TR_PREFS_KEY_ENCRYPTION, "required" ); 1820 1828 break; -
trunk/daemon/transmission-remote.1
r10729 r10798 22 22 .Op Fl c Ar path | Fl C 23 23 .Op Fl d Ar number | Fl D 24 .Op Fl e Ar size 24 25 .Op Fl er | ep | et 25 26 .Op Fl f … … 125 126 Disable download speed limits. 126 127 If current torrent(s) are selected this operates on them. Otherwise, it changes the global setting. 128 .It Fl e Fl -cache Ar size 129 Set the session's maximum memory cache size in MiB. This cache is used to reduce disk IO. 127 130 .It Fl er Fl -encryption-required 128 131 Encrypt all peer connections. -
trunk/doc/rpc-spec.txt
r10638 r10798 400 400 "blocklist-enabled" | boolean true means enabled 401 401 "blocklist-size" | number number of rules in the blocklist 402 "cache-size-MiB" | number size (in MiB) of the disk cache 402 403 "config-dir" | string location of transmission's configuration directory 403 404 "download-dir" | string default path to download torrents … … 598 599 | 2.00 | yes | session-get | new arg "start-added-torrents" 599 600 | 2.00 | yes | session-get | new arg "trash-original-torrent-files" 601 | 2.00 | yes | session-get | new arg "cache-size-MiB" 600 602 | 2.00 | yes | torrent-get | new arg "isFinished" -
trunk/gtk/my-valgrind.sh
r10332 r10798 3 3 export G_DEBUG=gc-friendly 4 4 export GLIBCXX_FORCE_NEW=1 5 valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=48 --log-file=x-valgrind --show-reachable=yes ./transmission -p 2>&1 | tee runlog 5 valgrind --tool=cachegrind ./transmission -p -g /tmp/transmission-test/what 2>&1 | tee runlog 6 #valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=48 --log-file=x-valgrind --show-reachable=yes ./transmission -p -g /tmp/transmission-test/what 2>&1 | tee runlog -
trunk/libtransmission/Makefile.am
r10754 r10798 22 22 bitfield.c \ 23 23 blocklist.c \ 24 cache.c \ 24 25 clients.c \ 25 26 completion.c \ … … 72 73 bitset.h \ 73 74 blocklist.h \ 75 cache.h \ 74 76 clients.h \ 75 77 ConvertUTF.h \ -
trunk/libtransmission/inout.c
r10552 r10798 27 27 28 28 #include "transmission.h" 29 #include "cache.h" 29 30 #include "crypto.h" 30 31 #include "fdlimit.h" 31 32 #include "inout.h" 33 #include "peer-common.h" /* MAX_BLOCK_SIZE */ 32 34 #include "platform.h" 33 35 #include "stats.h" … … 84 86 int err = 0; 85 87 const tr_bool doWrite = ioMode >= TR_IO_WRITE; 88 89 if( doWrite ) 90 fprintf( stderr, "in file %s at offset %zu, writing %zu bytes; file length is %zu\n", file->name, (size_t)fileOffset, buflen, (size_t)file->length ); 86 91 87 92 assert( fileIndex < info->fileCount ); … … 224 229 if( pieceIndex >= tor->info.pieceCount ) 225 230 return EINVAL; 226 if( pieceOffset + buflen > tr_torPieceCountBytes( tor, pieceIndex ) )227 return EINVAL;231 //if( pieceOffset + buflen > tr_torPieceCountBytes( tor, pieceIndex ) ) 232 // return EINVAL; 228 233 229 234 tr_ioFindFileLocation( tor, pieceIndex, pieceOffset, … … 238 243 buf += bytesThisPass; 239 244 buflen -= bytesThisPass; 245 //fprintf( stderr, "++fileIndex to %d\n", (int)fileIndex ); 240 246 ++fileIndex; 241 247 fileOffset = 0; … … 296 302 uint32_t offset = 0; 297 303 tr_bool success = TRUE; 298 uint8_t * buffer = tr_sessionGetBuffer( tor->session );299 const size_t buflen = SESSION_BUFFER_SIZE;304 const size_t buflen = MAX_BLOCK_SIZE; 305 uint8_t * buffer = tr_new( uint8_t, buflen ); 300 306 SHA_CTX sha; 301 307 … … 314 320 { 315 321 const int len = MIN( bytesLeft, buflen ); 316 success = !tr_ ioRead(tor, pieceIndex, offset, len, buffer );322 success = !tr_cacheReadBlock( tor->session->cache, tor, pieceIndex, offset, len, buffer ); 317 323 if( !success ) 318 324 break; … … 325 331 SHA1_Final( setme, &sha ); 326 332 327 tr_ sessionReleaseBuffer( tor->session);333 tr_free( buffer ); 328 334 return success; 329 335 } -
trunk/libtransmission/peer-mgr.c
r10752 r10798 22 22 #include "bencode.h" 23 23 #include "blocklist.h" 24 #include "cache.h" 24 25 #include "clients.h" 25 26 #include "completion.h" … … 1499 1500 for( fileIndex=0; fileIndex<tor->info.fileCount; ++fileIndex ) { 1500 1501 const tr_file * file = &tor->info.files[fileIndex]; 1501 if( ( file->firstPiece <= p ) && ( p <= file->lastPiece ) ) 1502 if( tr_cpFileIsComplete( &tor->completion, fileIndex ) ) 1502 if( ( file->firstPiece <= p ) && ( p <= file->lastPiece ) ) { 1503 if( tr_cpFileIsComplete( &tor->completion, fileIndex ) ) { 1504 fprintf( stderr, "flushing complete file %d (%s)\n", fileIndex, tor->info.files[fileIndex].name ); 1505 tr_cacheFlushFile( tor->session->cache, tor, fileIndex ); 1503 1506 tr_torrentFileCompleted( tor, fileIndex ); 1507 } 1508 } 1504 1509 } 1505 1510 -
trunk/libtransmission/peer-msgs.c
r10737 r10798 23 23 #include "transmission.h" 24 24 #include "bencode.h" 25 #include "cache.h" 25 26 #include "completion.h" 26 27 #include "crypto.h" 27 #include "inout.h"28 28 #ifdef WIN32 29 29 #include "net.h" /* for ECONN */ … … 1212 1212 { 1213 1213 const struct peer_request * req = msgs->peerAskedFor + i; 1214 tr_ ioPrefetch(msgs->torrent, req->index, req->offset, req->length );1214 tr_cachePrefetchBlock( getSession(msgs)->cache, msgs->torrent, req->index, req->offset, req->length ); 1215 1215 ++msgs->prefetchCount; 1216 1216 } … … 1602 1602 **/ 1603 1603 1604 if(( err = tr_ ioWrite(tor, req->index, req->offset, req->length, data )))1604 if(( err = tr_cacheWriteBlock( getSession(msgs)->cache, tor, req->index, req->offset, req->length, data ))) 1605 1605 return err; 1606 1606 … … 1914 1914 tr_peerIoWriteUint32( io, out, req.offset ); 1915 1915 1916 err = tr_ ioRead(msgs->torrent, req.index, req.offset, req.length, EVBUFFER_DATA(out)+EVBUFFER_LENGTH(out) );1916 err = tr_cacheReadBlock( getSession(msgs)->cache, msgs->torrent, req.index, req.offset, req.length, EVBUFFER_DATA(out)+EVBUFFER_LENGTH(out) ); 1917 1917 if( err ) 1918 1918 { -
trunk/libtransmission/ptrarray.c
r10349 r10798 103 103 } 104 104 105 staticvoid105 void 106 106 tr_ptrArrayErase( tr_ptrArray * t, 107 107 int begin, … … 124 124 **/ 125 125 126 staticint126 int 127 127 tr_ptrArrayLowerBound( const tr_ptrArray * t, 128 128 const void * ptr, … … 185 185 const int ret = tr_ptrArrayInsert( t, ptr, pos ); 186 186 187 assertSortedAndUnique( t, compare );187 //assertSortedAndUnique( t, compare ); 188 188 return ret; 189 189 } -
trunk/libtransmission/ptrarray.h
r10030 r10798 66 66 } 67 67 68 void tr_ptrArrayErase( tr_ptrArray * t, int begin, int end ); 69 70 68 71 69 72 /** @brief Peek at the array pointer and its size, for easy iteration */ … … 101 104 } 102 105 106 int tr_ptrArrayLowerBound( const tr_ptrArray * array, 107 const void * key, 108 int compare( const void * arrayItem, const void * key ), 109 tr_bool * exact_match ); 110 103 111 /** @brief Insert a pointer into the array at the position determined by the sort function 104 112 @return the index of the stored pointer */ -
trunk/libtransmission/rpcimpl.c
r10638 r10798 1185 1185 assert( idle_data == NULL ); 1186 1186 1187 if( tr_bencDictFindReal( args_in, TR_PREFS_KEY_MAX_CACHE_SIZE_MiB, &d ) ) 1188 tr_sessionSetCacheLimit( session, d ); 1187 1189 if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_ALT_SPEED_UP, &i ) ) 1188 1190 tr_sessionSetAltSpeed( session, TR_UP, i ); … … 1324 1326 tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED, tr_sessionUsesAltSpeedTime(s) ); 1325 1327 tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED, tr_blocklistIsEnabled( s ) ); 1328 tr_bencDictAddReal( d, TR_PREFS_KEY_MAX_CACHE_SIZE_MiB, tr_sessionGetCacheLimit( s ) ); 1326 1329 tr_bencDictAddInt ( d, "blocklist-size", tr_blocklistGetRuleCount( s ) ); 1327 1330 tr_bencDictAddStr ( d, "config-dir", tr_sessionGetConfigDir( s ) ); -
trunk/libtransmission/session.c
r10751 r10798 29 29 #include "bencode.h" 30 30 #include "blocklist.h" 31 #include "cache.h" 31 32 #include "crypto.h" 32 33 #include "fdlimit.h" … … 52 53 enum 53 54 { 54 SAVE_INTERVAL_SECS = 120 55 SAVE_INTERVAL_SECS = 120, 56 57 DEFAULT_CACHE_SIZE_MiB = 2 /* 2 MiB */ 55 58 }; 56 59 … … 243 246 assert( tr_bencIsDict( d ) ); 244 247 245 tr_bencDictReserve( d, 35);248 tr_bencDictReserve( d, 60 ); 246 249 tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED, FALSE ); 250 tr_bencDictAddReal( d, TR_PREFS_KEY_MAX_CACHE_SIZE_MiB, DEFAULT_CACHE_SIZE_MiB ); 247 251 tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED, TRUE ); 248 252 tr_bencDictAddBool( d, TR_PREFS_KEY_LPD_ENABLED, FALSE ); … … 308 312 assert( tr_bencIsDict( d ) ); 309 313 310 tr_bencDictReserve( d, 30 );314 tr_bencDictReserve( d, 60 ); 311 315 tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED, tr_blocklistIsEnabled( s ) ); 316 tr_bencDictAddReal( d, TR_PREFS_KEY_MAX_CACHE_SIZE_MiB, tr_cacheGetLimit( s->cache ) ); 312 317 tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED, s->isDHTEnabled ); 313 318 tr_bencDictAddBool( d, TR_PREFS_KEY_LPD_ENABLED, s->isLPDEnabled ); … … 507 512 session->bandwidth = tr_bandwidthNew( session, NULL ); 508 513 session->lock = tr_lockNew( ); 514 session->cache = tr_cacheNew( DEFAULT_CACHE_SIZE_MiB ); 509 515 session->tag = tr_strdup( tag ); 510 516 session->magicNumber = SESSION_MAGIC_NUMBER; … … 672 678 673 679 /* misc features */ 680 if( tr_bencDictFindReal( settings, TR_PREFS_KEY_MAX_CACHE_SIZE_MiB, &d ) ) 681 tr_sessionSetCacheLimit( session, d ); 674 682 if( tr_bencDictFindBool( settings, TR_PREFS_KEY_LAZY_BITFIELD, &boolVal ) ) 675 683 tr_sessionSetLazyBitfieldEnabled( session, boolVal ); … … 1606 1614 tr_free( torrents ); 1607 1615 1616 tr_cacheFree( session->cache ); 1617 session->cache = NULL; 1608 1618 tr_announcerClose( session ); 1609 1619 tr_statsClose( session ); … … 1833 1843 { 1834 1844 return tr_sessionIsLPDEnabled( session ); 1845 } 1846 1847 /*** 1848 **** 1849 ***/ 1850 1851 void 1852 tr_sessionSetCacheLimit( tr_session * session, double maxMiB ) 1853 { 1854 assert( tr_isSession( session ) ); 1855 1856 tr_cacheSetLimit( session->cache, maxMiB ); 1857 } 1858 1859 double 1860 tr_sessionGetCacheLimit( const tr_session * session ) 1861 { 1862 assert( tr_isSession( session ) ); 1863 1864 return tr_cacheGetLimit( session->cache ); 1835 1865 } 1836 1866 -
trunk/libtransmission/session.h
r10638 r10798 41 41 struct tr_bandwidth; 42 42 struct tr_bindsockets; 43 struct tr_cache; 43 44 struct tr_fdInfo; 44 45 … … 150 151 struct tr_shared * shared; 151 152 153 struct tr_cache * cache; 154 152 155 struct tr_lock * lock; 153 156 -
trunk/libtransmission/torrent.c
r10774 r10798 30 30 #include "bandwidth.h" 31 31 #include "bencode.h" 32 #include "cache.h" 32 33 #include "completion.h" 33 34 #include "crypto.h" /* for tr_sha1 */ … … 1517 1518 tr_peerMgrStopTorrent( tor ); 1518 1519 tr_announcerTorrentStopped( tor ); 1520 tr_cacheFlushTorrent( tor->session->cache, tor ); 1519 1521 1520 1522 tr_fdTorrentClose( tor->session, tor->uniqueId ); -
trunk/libtransmission/transmission.h
r10697 r10798 164 164 #define TR_PREFS_KEY_BIND_ADDRESS_IPV6 "bind-address-ipv6" 165 165 #define TR_PREFS_KEY_BLOCKLIST_ENABLED "blocklist-enabled" 166 #define TR_PREFS_KEY_MAX_CACHE_SIZE_MiB "cache-size-MiB" 166 167 #define TR_PREFS_KEY_DHT_ENABLED "dht-enabled" 167 168 #define TR_PREFS_KEY_LPD_ENABLED "lpd-enabled" … … 587 588 * In public torrents, PEX is enabled by default. 588 589 */ 589 void tr_sessionSetPexEnabled( tr_session * session, tr_bool isEnabled ); 590 591 tr_bool tr_sessionIsPexEnabled( const tr_session * session ); 592 593 tr_bool tr_sessionIsDHTEnabled( const tr_session * session ); 594 595 void tr_sessionSetDHTEnabled( tr_session * session, tr_bool ); 596 597 tr_bool tr_sessionIsLPDEnabled( const tr_session * session ); 598 599 void tr_sessionSetLPDEnabled( tr_session * session, tr_bool enabled ); 600 601 void tr_sessionSetLazyBitfieldEnabled( tr_session * session, 602 tr_bool enabled ); 603 604 tr_bool tr_sessionIsLazyBitfieldEnabled( const tr_session * session ); 590 void tr_sessionSetPexEnabled( tr_session * session, tr_bool isEnabled ); 591 tr_bool tr_sessionIsPexEnabled( const tr_session * session ); 592 593 tr_bool tr_sessionIsDHTEnabled( const tr_session * session ); 594 void tr_sessionSetDHTEnabled( tr_session * session, tr_bool ); 595 596 tr_bool tr_sessionIsLPDEnabled( const tr_session * session ); 597 void tr_sessionSetLPDEnabled( tr_session * session, tr_bool enabled ); 598 599 void tr_sessionSetCacheLimit( tr_session * session, double MiB ); 600 double tr_sessionGetCacheLimit( const tr_session * session ); 601 602 void tr_sessionSetLazyBitfieldEnabled( tr_session * session, tr_bool enabled ); 603 tr_bool tr_sessionIsLazyBitfieldEnabled( const tr_session * session ); 605 604 606 605 tr_encryption_mode tr_sessionGetEncryption( tr_session * session ); 607 608 void tr_sessionSetEncryption( tr_session * session, 606 void tr_sessionSetEncryption( tr_session * session, 609 607 tr_encryption_mode mode ); 610 608
Note: See TracChangeset
for help on using the changeset viewer.