Skip to content

Commit 6c88015

Browse files
committed
fix bug in auto disk cache size logic
1 parent 71e3bee commit 6c88015

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* fix bug in auto disk cache size logic
12
* fix issue with outgoing_interfaces setting, where bind() would be called twice
23
* add build option to disable share-mode
34
* support validation of HTTPS trackers

include/libtorrent/settings_pack.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ namespace aux {
7878
, aux::session_settings_single_thread& sett
7979
, std::vector<void(aux::session_impl::*)()>* callbacks = nullptr);
8080
TORRENT_EXTRA_EXPORT void run_all_updates(aux::session_impl& ses);
81+
TORRENT_EXTRA_EXPORT int default_int_value(int const name);
8182

8283
// converts a setting integer (from the enums string_types, int_types or
8384
// bool_types) to a string, and vice versa.

src/disk_buffer_pool.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ namespace libtorrent {
292292
if (cache_size < 0)
293293
{
294294
std::int64_t phys_ram = total_physical_ram();
295-
if (phys_ram == 0) m_max_use = 1024;
295+
if (phys_ram == 0) m_max_use = default_int_value(settings_pack::cache_size);
296296
else
297297
{
298298
// this is the logic to calculate the automatic disk cache size

src/platform_util.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ namespace libtorrent {
112112
MEMORYSTATUSEX ms;
113113
ms.dwLength = sizeof(MEMORYSTATUSEX);
114114
if (GlobalMemoryStatusEx(&ms))
115-
ret = int(ms.ullTotalPhys);
115+
ret = ms.ullTotalPhys;
116116
else
117117
ret = 0;
118118
#elif defined TORRENT_LINUX

src/settings_pack.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,12 @@ constexpr int CLOSE_FILE_INTERVAL = 0;
531531
return ret;
532532
}
533533

534+
int default_int_value(int const name)
535+
{
536+
TORRENT_ASSERT((name & settings_pack::type_mask) == settings_pack::int_type_base);
537+
return int_settings[name - settings_pack::int_type_base].default_value;
538+
}
539+
534540
void apply_pack(settings_pack const* pack, aux::session_settings& sett
535541
, aux::session_impl* ses)
536542
{

0 commit comments

Comments
 (0)