diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 707761ff2..f0ce251a2 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -280,6 +280,11 @@ Session::Session(QObject *parent) , m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60) , m_useOSCache(BITTORRENT_SESSION_KEY("UseOSCache"), true) , m_guidedReadCacheEnabled(BITTORRENT_SESSION_KEY("GuidedReadCache"), true) +#ifdef Q_OS_WIN + , m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY("CoalesceReadWrite"), true) +#else + , m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY("CoalesceReadWrite"), false) +#endif , m_isSuggestMode(BITTORRENT_SESSION_KEY("SuggestMode"), false) , m_sendBufferWatermark(BITTORRENT_SESSION_KEY("SendBufferWatermark"), 500) , m_sendBufferLowWatermark(BITTORRENT_SESSION_KEY("SendBufferLowWatermark"), 10) @@ -1303,6 +1308,10 @@ void Session::configure(libtorrent::settings_pack &settingsPack) settingsPack.set_int(libt::settings_pack::disk_io_read_mode, mode); settingsPack.set_int(libt::settings_pack::disk_io_write_mode, mode); settingsPack.set_bool(libt::settings_pack::guided_read_cache, isGuidedReadCacheEnabled()); + + settingsPack.set_bool(libt::settings_pack::coalesce_reads, isCoalesceReadWriteEnabled()); + settingsPack.set_bool(libt::settings_pack::coalesce_writes, isCoalesceReadWriteEnabled()); + settingsPack.set_int(libt::settings_pack::suggest_mode, isSuggestModeEnabled() ? libt::settings_pack::suggest_read_cache : libt::settings_pack::no_piece_suggestions); @@ -3049,6 +3058,19 @@ void Session::setGuidedReadCacheEnabled(bool enabled) configureDeferred(); } +bool Session::isCoalesceReadWriteEnabled() const +{ + return m_coalesceReadWriteEnabled; +} + +void Session::setCoalesceReadWriteEnabled(bool enabled) +{ + if (enabled == m_coalesceReadWriteEnabled) return; + + m_coalesceReadWriteEnabled = enabled; + configureDeferred(); +} + bool Session::isSuggestModeEnabled() const { return m_isSuggestMode; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 0e219fb1d..09082dd1f 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -382,6 +382,8 @@ namespace BitTorrent void setUseOSCache(bool use); bool isGuidedReadCacheEnabled() const; void setGuidedReadCacheEnabled(bool enabled); + bool isCoalesceReadWriteEnabled() const; + void setCoalesceReadWriteEnabled(bool enabled); bool isSuggestModeEnabled() const; void setSuggestMode(bool mode); int sendBufferWatermark() const; @@ -646,6 +648,7 @@ namespace BitTorrent CachedSettingValue m_diskCacheTTL; CachedSettingValue m_useOSCache; CachedSettingValue m_guidedReadCacheEnabled; + CachedSettingValue m_coalesceReadWriteEnabled; CachedSettingValue m_isSuggestMode; CachedSettingValue m_sendBufferWatermark; CachedSettingValue m_sendBufferLowWatermark; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index d209a4988..eabef3ed5 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -82,6 +82,7 @@ enum AdvSettingsRows DISK_CACHE_TTL, OS_CACHE, GUIDED_READ_CACHE, + COALESCE_RW, SUGGEST_MODE, SEND_BUF_WATERMARK, SEND_BUF_LOW_WATERMARK, @@ -142,6 +143,8 @@ void AdvancedSettings::saveAdvancedSettings() session->setUseOSCache(cb_os_cache.isChecked()); // Guided read cache session->setGuidedReadCacheEnabled(cbGuidedReadCache.isChecked()); + // Coalesce reads & writes + session->setCoalesceReadWriteEnabled(cbCoalesceRW.isChecked()); // Suggest mode session->setSuggestMode(cbSuggestMode.isChecked()); // Send buffer watermark @@ -313,6 +316,11 @@ void AdvancedSettings::loadAdvancedSettings() // Guided read cache cbGuidedReadCache.setChecked(session->isGuidedReadCacheEnabled()); addRow(GUIDED_READ_CACHE, tr("Guided read cache"), &cbGuidedReadCache); + // Coalesce reads & writes + cbCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled()); +#if LIBTORRENT_VERSION_NUM >= 10107 + addRow(COALESCE_RW, tr("Coalesce reads & writes"), &cbCoalesceRW); +#endif // Suggest mode cbSuggestMode.setChecked(session->isSuggestModeEnabled()); addRow(SUGGEST_MODE, tr("Send upload piece suggestions"), &cbSuggestMode); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 78e976577..8c1893c00 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -80,7 +80,7 @@ private: QCheckBox cb_os_cache, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts, cb_super_seeding, cb_program_notifications, cb_torrent_added_notifications, cb_tracker_favicon, cb_tracker_status, cb_confirm_torrent_recheck, cb_confirm_remove_all_tags, cb_listen_ipv6, cb_announce_all_trackers, cb_announce_all_tiers, - cbGuidedReadCache, cbMultiConnectionsPerIp, cbSuggestMode; + cbGuidedReadCache, cbMultiConnectionsPerIp, cbSuggestMode, cbCoalesceRW; QComboBox combo_iface, combo_iface_address, comboUtpMixedMode, comboChokingAlgorithm, comboSeedChokingAlgorithm; QLineEdit txtAnnounceIP;