From ed8fffc1a6a5483e88995d4be091c00351268dfc Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 21 May 2018 14:10:49 +0200 Subject: [PATCH 1/5] set the hidden attribute when creating the part file --- ChangeLog | 1 + src/part_file.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b5bdd743..a8258a171 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ + * set the hidden attribute when creating the part file * fix recent regression with force_proxy setting * don't perform DNS lookups for the DHT bootstrap unless DHT is enabled * fix issue where setting file/piece priority would stop checking diff --git a/src/part_file.cpp b/src/part_file.cpp index a4291e509..45a554bac 100644 --- a/src/part_file.cpp +++ b/src/part_file.cpp @@ -180,7 +180,7 @@ namespace libtorrent TORRENT_ASSERT(offset >= 0); mutex::scoped_lock l(m_mutex); - open_file(file::read_write, ec); + open_file(file::read_write | file::attribute_hidden, ec); if (ec) return -1; int slot = -1; @@ -212,7 +212,7 @@ namespace libtorrent int slot = i->second; - open_file(file::read_write, ec); + open_file(file::read_write | file::attribute_hidden, ec); if (ec) return -1; l.unlock(); @@ -393,7 +393,7 @@ namespace libtorrent return; } - open_file(file::read_write, ec); + open_file(file::read_write | file::attribute_hidden, ec); if (ec) return; boost::scoped_array header(new boost::uint32_t[m_header_size / 4]); From 77191a38205105adbe14c64f86d14ded5986ffc4 Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 22 May 2018 09:29:54 +0200 Subject: [PATCH 2/5] fix hidden attribute in file class --- src/file.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index 32c711761..0db8f56eb 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1419,14 +1419,14 @@ namespace libtorrent TORRENT_ASSERT((mode & rw_mask) < sizeof(mode_array)/sizeof(mode_array[0])); open_mode_t const& m = mode_array[mode & rw_mask]; - DWORD a = attrib_array[(mode & attribute_mask) >> 12]; + DWORD const a = attrib_array[(mode & attribute_mask) >> 9]; // one might think it's a good idea to pass in FILE_FLAG_RANDOM_ACCESS. It // turns out that it isn't. That flag will break your operating system: // http://support.microsoft.com/kb/2549369 DWORD flags = ((mode & random_access) ? 0 : FILE_FLAG_SEQUENTIAL_SCAN) - | (a ? a : FILE_ATTRIBUTE_NORMAL) + | a | FILE_FLAG_OVERLAPPED | ((mode & no_cache) ? FILE_FLAG_WRITE_THROUGH : 0); From 6ec6c1b34055c226f7f869cf213a995a574c1606 Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 23 May 2018 12:40:52 +0200 Subject: [PATCH 3/5] since moving an existing file into the part file isn't supported, just don't use the partfile for existing files when their priority is set to 0 --- src/storage.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/storage.cpp b/src/storage.cpp index e444b7f3a..11261b3d6 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -477,11 +477,10 @@ namespace libtorrent { // move stuff into the part file // this is not implemented yet. - // pretend that we didn't set the priority to 0. + // so we just don't use a partfile for this file - std::string fp = fs.file_path(i, m_save_path); - if (exists(fp)) - new_prio = 1; + std::string const fp = fs.file_path(i, m_save_path); + if (exists(fp)) use_partfile(i, false); /* file_handle f = open_file(i, file::read_only, ec); if (ec.ec != boost::system::errc::no_such_file_or_directory) From 35d76724321b224f455b4c08b6e1e1290b4f81c6 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 26 May 2018 14:27:24 +0200 Subject: [PATCH 4/5] raise priority of fastresum_rejected_alert --- include/libtorrent/alert_types.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index b44831327..50f83706a 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -1472,7 +1472,7 @@ namespace libtorrent , std::string const& file , char const* op); - TORRENT_DEFINE_ALERT(fastresume_rejected_alert, 53) + TORRENT_DEFINE_ALERT_PRIO(fastresume_rejected_alert, 53, alert_priority_critical) static const int static_category = alert::status_notification | alert::error_notification; From b1d7dd89c14c2bd34fdb1fe6d4ae4f7594c00cca Mon Sep 17 00:00:00 2001 From: Eugene Shalygin Date: Fri, 25 May 2018 11:13:48 +0200 Subject: [PATCH 5/5] Reflect Boost version and C++11/14 interconnection in CMake build C++ standard and Boost requirements are connected: 1. With C++11 onward, we require Boost system component, with C++03 we need chrono and random components too 2. When building against boost 1.66 and newer, C++11 is required. Closes #3011, partially closes #2966. --- CMakeLists.txt | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 970eac352..5bdf15790 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.8) project(libtorrent) set (SOVERSION "8") set (VERSION "1.1.7") @@ -253,10 +253,38 @@ endif() target_compile_definitions(torrent-rasterbar PRIVATE TORRENT_BUILDING_LIBRARY) +# C++ standard and Boost requirements are connected: +# 1. With C++11 onward, we require Boost system component, with C++03 we need chrono and random components too +# 2. When building against boost 1.66 and newer, C++11 is required. + +# For the first requirement we do: +set(required_boost_components system) +if (NOT cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + list(APPEND required_boost_components chrono random) +endif() # Boost if(NOT DEFINED Boost_INCLUDE_DIR OR NOT DEFINED Boost_LIBRARIES) - FIND_PACKAGE(Boost REQUIRED COMPONENTS system chrono random) + find_package(Boost REQUIRED COMPONENTS ${required_boost_components}) endif() +# now test the second requirement: +if (Boost_VERSION VERSION_GREATER_EQUAL 106600) + if (NOT cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + message(FATAL_ERROR "When building against boost 1.66 and newer, C++11 is required,\n" + "and your compiler does not support that") + endif() +endif() + +# selecting C++14/11 mode if available +if (cxx_std_14 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + target_compile_features(torrent-rasterbar PUBLIC cxx_std_14) + message(STATUS "Building in C++14 mode") + set(CXX_MODE_COMPILE_OPTION -std=c++14) +elseif(cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + target_compile_features(torrent-rasterbar PUBLIC cxx_std_11) + message(STATUS "Building in C++11 mode") + set(CXX_MODE_COMPILE_OPTION -std=c++11) +endif() + include_directories(${Boost_INCLUDE_DIRS}) target_link_libraries(torrent-rasterbar ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) @@ -342,6 +370,8 @@ get_property (COMPILETIME_OPTIONS_LIST DIRECTORY ${CMAKE_CURRENT_SOURCE_DIRECTORY} PROPERTY COMPILE_DEFINITIONS ) + +set(COMPILETIME_OPTIONS ${CXX_MODE_COMPILE_OPTION}) foreach (s ${COMPILETIME_OPTIONS_LIST}) set (COMPILETIME_OPTIONS "${COMPILETIME_OPTIONS} -D${s}") endforeach (s)