mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07:00
Allow to use POSIX-compliant disk IO type
This patch allows user to switch disk IO type between memory mapped files based type (default in libtorrent 2, and seems causing memory issues) and POSIX-compliant type which is more conservative on memory usage. Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com> Co-authored-by: Vladimir Golovnev (Glassez) <glassez@yandex.ru> PR #16895.
This commit is contained in:
parent
a048ea668f
commit
e698c09298
8 changed files with 90 additions and 1 deletions
|
@ -381,6 +381,7 @@ Session::Session(QObject *parent)
|
|||
, m_diskCacheSize(BITTORRENT_SESSION_KEY(u"DiskCacheSize"_qs), -1)
|
||||
, m_diskCacheTTL(BITTORRENT_SESSION_KEY(u"DiskCacheTTL"_qs), 60)
|
||||
, m_diskQueueSize(BITTORRENT_SESSION_KEY(u"DiskQueueSize"_qs), (1024 * 1024))
|
||||
, m_diskIOType(BITTORRENT_SESSION_KEY(u"DiskIOType"_qs), DiskIOType::Default)
|
||||
, m_useOSCache(BITTORRENT_SESSION_KEY(u"UseOSCache"_qs), true)
|
||||
#ifdef Q_OS_WIN
|
||||
, m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY(u"CoalesceReadWrite"_qs), true)
|
||||
|
@ -1149,7 +1150,18 @@ void Session::initializeNativeSession()
|
|||
loadLTSettings(pack);
|
||||
lt::session_params sessionParams {pack, {}};
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
sessionParams.disk_io_constructor = customDiskIOConstructor;
|
||||
switch (diskIOType())
|
||||
{
|
||||
case DiskIOType::Posix:
|
||||
sessionParams.disk_io_constructor = customPosixDiskIOConstructor;
|
||||
break;
|
||||
case DiskIOType::MMap:
|
||||
sessionParams.disk_io_constructor = customMMapDiskIOConstructor;
|
||||
break;
|
||||
default:
|
||||
sessionParams.disk_io_constructor = customDiskIOConstructor;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
m_nativeSession = new lt::session {sessionParams};
|
||||
|
||||
|
@ -3363,6 +3375,19 @@ void Session::setPeerTurnoverInterval(const int val)
|
|||
configureDeferred();
|
||||
}
|
||||
|
||||
DiskIOType Session::diskIOType() const
|
||||
{
|
||||
return m_diskIOType;
|
||||
}
|
||||
|
||||
void Session::setDiskIOType(const DiskIOType type)
|
||||
{
|
||||
if (type != m_diskIOType)
|
||||
{
|
||||
m_diskIOType = type;
|
||||
}
|
||||
}
|
||||
|
||||
int Session::requestQueueSize() const
|
||||
{
|
||||
return m_requestQueueSize;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue