From d6c8184381b120a0ec02e45e54c306043eb1260e Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 9 Jun 2011 06:08:24 +0000 Subject: [PATCH] support locking files --- docs/manual.html | 7 ++- docs/manual.rst | 8 +++- include/libtorrent/file.hpp | 2 +- include/libtorrent/session_settings.hpp | 5 +++ src/file.cpp | 60 ++++++++++++++++--------- src/storage.cpp | 2 + 6 files changed, 61 insertions(+), 23 deletions(-) diff --git a/docs/manual.html b/docs/manual.html index 3d94ed206..7054120d2 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -4393,7 +4393,8 @@ struct session_settings bool always_send_user_agent; bool apply_ip_filter_to_trackers; int read_job_every; - use_disk_read_ahead; + bool use_disk_read_ahead; + bool lock_files; };

version is automatically set to the libtorrent version you're using @@ -5115,6 +5116,10 @@ instead pick one read job off of the sorted queue, where x is use_disk_read_ahead defaults to true and will attempt to optimize disk reads by giving the operating system heads up of disk read requests as they are queued in the disk job queue. This gives a significant performance boost for seeding.

+

lock_files determines whether or not to lock files which libtorrent is downloading +to or seeding from. This is implemented using fcntl(F_SETLK) on unix systems and +by not passing in SHARE_READ and SHARE_WRITE on windows. This might prevent +3rd party processes from corrupting the files under libtorrent's feet.

diff --git a/docs/manual.rst b/docs/manual.rst index 4c587fcea..4a404ef9f 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -4405,7 +4405,8 @@ session_settings bool always_send_user_agent; bool apply_ip_filter_to_trackers; int read_job_every; - use_disk_read_ahead; + bool use_disk_read_ahead; + bool lock_files; }; ``version`` is automatically set to the libtorrent version you're using @@ -5274,6 +5275,11 @@ instead pick one read job off of the sorted queue, where *x* is ``read_job_every by giving the operating system heads up of disk read requests as they are queued in the disk job queue. This gives a significant performance boost for seeding. +``lock_files`` determines whether or not to lock files which libtorrent is downloading +to or seeding from. This is implemented using ``fcntl(F_SETLK)`` on unix systems and +by not passing in ``SHARE_READ`` and ``SHARE_WRITE`` on windows. This might prevent +3rd party processes from corrupting the files under libtorrent's feet. + pe_settings =========== diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index dd5fd1f12..4fb9c6489 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -182,10 +182,10 @@ namespace libtorrent read_write = 2, rw_mask = read_only | write_only | read_write, no_buffer = 4, - mode_mask = rw_mask | no_buffer, sparse = 8, no_atime = 16, random_access = 32, + lock_file = 64, attribute_hidden = 0x1000, attribute_executable = 0x2000, HTTP/1.1 200 OK Content-Type: text/plain; charset=utf-8 Connection: close Transfer-Encoding: chunked Cache-Control: max-age=0, private, must-revalidate, no-transform Set-Cookie: i_like_gitea=7631ee95d9c6089e; Path=/; HttpOnly; Secure; SameSite=Lax Set-Cookie: _csrf=Ubmw5RyCOMhcLMq4TC9VmCVJWJc6MTc1MzI2ODk0Nzc0MTg3MzU5NQ; Path=/; Max-Age=86400; HttpOnly; Secure; SameSite=Lax X-Frame-Options: SAMEORIGIN Date: Wed, 23 Jul 2025 11:09:07 GMT X-Cache-Status: HIT X-Cache-Age: 0 1f8d From d6c8184381b120a0ec02e45e54c306043eb1260e Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 9 Jun 2011 06:08:24 +0000 Subject: [PATCH] support locking files --- docs/manual.html | 7 ++- docs/manual.rst | 8 +++- include/libtorrent/file.hpp | 2 +- include/libtorrent/session_settings.hpp | 5 +++ src/file.cpp | 60 ++++++++++++++++--------- src/storage.cpp | 2 + 6 files changed, 61 insertions(+), 23 deletions(-) diff --git a/docs/manual.html b/docs/manual.html index 3d94ed206..7054120d2 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -4393,7 +4393,8 @@ struct session_settings bool always_send_user_agent; bool apply_ip_filter_to_trackers; int read_job_every; - use_disk_read_ahead; + bool use_disk_read_ahead; + bool lock_files; };

version is automatically set to the libtorrent version you're using @@ -5115,6 +5116,10 @@ instead pick one read job off of the sorted queue, where x is use_disk_read_ahead defaults to true and will attempt to optimize disk reads by giving the operating system heads up of disk read requests as they are queued in the disk job queue. This gives a significant performance boost for seeding.

+

lock_files determines whether or not to lock files which libtorrent is downloading +to or seeding from. This is implemented using fcntl(F_SETLK) on unix systems and +by not passing in SHARE_READ and SHARE_WRITE on windows. This might prevent +3rd party processes from corrupting the files under libtorrent's feet.

diff --git a/docs/manual.rst b/docs/manual.rst index 4c587fcea..4a404ef9f 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -4405,7 +4405,8 @@ session_settings bool always_send_user_agent; bool apply_ip_filter_to_trackers; int read_job_every; - use_disk_read_ahead; + bool use_disk_read_ahead; + bool lock_files; }; ``version`` is automatically set to the libtorrent version you're using @@ -5274,6 +5275,11 @@ instead pick one read job off of the sorted queue, where *x* is ``read_job_every by giving the operating system heads up of disk read requests as they are queued in the disk job queue. This gives a significant performance boost for seeding. +``lock_files`` determines whether or not to lock files which libtorrent is downloading +to or seeding from. This is implemented using ``fcntl(F_SETLK)`` on unix systems and +by not passing in ``SHARE_READ`` and ``SHARE_WRITE`` on windows. This might prevent +3rd party processes from corrupting the files under libtorrent's feet. + pe_settings =========== diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index dd5fd1f12..4fb9c6489 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -182,10 +182,10 @@ namespace libtorrent read_write = 2, rw_mask = read_only | write_only | read_write, no_buffer = 4, - mode_mask = rw_mask | no_buffer, sparse = 8, no_atime = 16, random_access = 32, + lock_file = 64, attribute_hidden = 0x1000, attribute_executable = 0x2000, 0