From bfdb4458909946966e97a033d19d203c665c124f Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 23 Feb 2014 19:13:53 +0000 Subject: [PATCH] merged SetFileValidData fix from RC_0_16 --- ChangeLog | 1 + include/libtorrent/file.hpp | 2 ++ src/file.cpp | 10 ++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f5c5feda..28436214e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,6 +41,7 @@ * fix uTP edge case where udp socket buffer fills up * fix nagle implementation in uTP + * SetFileValidData fix on windows (prevents zero-fill) * fix minor lock_files issue on unix 0.16.15 release diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index 52bcec1fe..ca7b97e56 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -322,6 +322,8 @@ namespace libtorrent #endif #if defined TORRENT_WINDOWS mutable int m_cluster_size; + + static bool has_manage_volume_privs; #endif }; diff --git a/src/file.cpp b/src/file.cpp index f9e5d442c..5eed85350 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -946,6 +946,14 @@ namespace libtorrent }; #endif // TORRENT_WINDOWS + +#ifdef TORRENT_WINDOWS + bool get_manage_volume_privs(); + + // this needs to be run before CreateFile + bool file::has_manage_volume_privs = get_manage_volume_privs(); +#endif + file::file() #ifdef TORRENT_WINDOWS : m_file_handle(INVALID_HANDLE_VALUE) @@ -2025,8 +2033,6 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { void set_file_valid_data(HANDLE f, boost::int64_t size) { - static bool has_privs = get_manage_volume_privs(); - typedef BOOL (WINAPI *SetFileValidData_t)(HANDLE, LONGLONG); static SetFileValidData_t pSetFileValidData = NULL; static bool failed_kernel32 = false;