From eeca133dd7fbad700e73acd82d6ee1be7784d967 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 28 Jan 2018 01:34:18 +0100 Subject: [PATCH 1/2] fix alert_mask in bt-get.cpp --- examples/bt-get.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/bt-get.cpp b/examples/bt-get.cpp index 9eddf4924..5647780dd 100644 --- a/examples/bt-get.cpp +++ b/examples/bt-get.cpp @@ -47,7 +47,10 @@ int main(int argc, char const* argv[]) std::cerr << "usage: " << argv[0] << " " << std::endl; return 1; } - lt::session ses; + lt::settings_pack p; + p.set_int(lt::settings_pack::alert_mask, lt::alert::status_notification + | lt::alert::error_notification); + lt::session ses(p); lt::add_torrent_params atp; lt::error_code ec; From b729021625dabeb1d9976b880ebdfdeb504f5930 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 28 Jan 2018 01:38:24 +0100 Subject: [PATCH 2/2] make coalesce-buffers work on windows and systemps with pwritev()/preadv() --- ChangeLog | 1 + src/file.cpp | 24 ++++++------------------ 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index b5391b61d..ef32f3bff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ + * made coalesce_reads/coalesce_writes settings take effect on linux and windows * restore support for incoming connections over SOCKS5 (disabled by default) * use unique peer_ids per connection * fix iOS build on recent SDK diff --git a/src/file.cpp b/src/file.cpp index a34c34902..e6f8dc90e 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1663,7 +1663,6 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { namespace { -#if !TORRENT_USE_PREADV void gather_copy(file::iovec_t const* bufs, int num_bufs, char* dst) { std::size_t offset = 0; @@ -1717,7 +1716,6 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { num_bufs = 1; return true; } -#endif // TORRENT_USE_PREADV template boost::int64_t iov(Fun f, handle_type fd, boost::int64_t file_offset, file::iovec_t const* bufs_in @@ -1841,12 +1839,6 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { TORRENT_ASSERT(num_bufs > 0); TORRENT_ASSERT(is_open()); -#if TORRENT_USE_PREADV - TORRENT_UNUSED(flags); - - int ret = iov(&::preadv, native_handle(), file_offset, bufs, num_bufs, ec); -#else - // there's no point in coalescing single buffer writes if (num_bufs == 1) { @@ -1863,7 +1855,9 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { flags &= ~file::coalesce_buffers; } -#if TORRENT_USE_PREAD +#if TORRENT_USE_PREADV + int ret = iov(&::preadv, native_handle(), file_offset, bufs, num_bufs, ec); +#elif TORRENT_USE_PREAD int ret = iov(&::pread, native_handle(), file_offset, bufs, num_bufs, ec); #else int ret = iov(&::read, native_handle(), file_offset, bufs, num_bufs, ec); @@ -1873,7 +1867,6 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { coalesce_read_buffers_end(orig_bufs, orig_num_bufs , static_cast(tmp.iov_base), !ec); -#endif return ret; } @@ -1899,12 +1892,6 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { ec.clear(); -#if TORRENT_USE_PREADV - TORRENT_UNUSED(flags); - - int ret = iov(&::pwritev, native_handle(), file_offset, bufs, num_bufs, ec); -#else - // there's no point in coalescing single buffer writes if (num_bufs == 1) { @@ -1919,7 +1906,9 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { flags &= ~file::coalesce_buffers; } -#if TORRENT_USE_PREAD +#if TORRENT_USE_PREADV + int ret = iov(&::pwritev, native_handle(), file_offset, bufs, num_bufs, ec); +#elif TORRENT_USE_PREAD int ret = iov(&::pwrite, native_handle(), file_offset, bufs, num_bufs, ec); #else int ret = iov(&::write, native_handle(), file_offset, bufs, num_bufs, ec); @@ -1928,7 +1917,6 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { if (flags & file::coalesce_buffers) free(tmp.iov_base); -#endif #if TORRENT_USE_FDATASYNC \ && !defined F_NOCACHE && \ !defined DIRECTIO_ON