Coverage Report

Created: 2026-01-21 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libtorrent/src/session_handle.cpp
Line
Count
Source
1
/*
2
3
Copyright (c) 2014-2018, Steven Siloti
4
Copyright (c) 2015-2018, Alden Torres
5
Copyright (c) 2015-2022, Arvid Norberg
6
Copyright (c) 2025, Vladimir Golovnev (glassez)
7
All rights reserved.
8
9
Redistribution and use in source and binary forms, with or without
10
modification, are permitted provided that the following conditions
11
are met:
12
13
    * Redistributions of source code must retain the above copyright
14
      notice, this list of conditions and the following disclaimer.
15
    * Redistributions in binary form must reproduce the above copyright
16
      notice, this list of conditions and the following disclaimer in
17
      the documentation and/or other materials provided with the distribution.
18
    * Neither the name of the author nor the names of its
19
      contributors may be used to endorse or promote products derived
20
      from this software without specific prior written permission.
21
22
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
POSSIBILITY OF SUCH DAMAGE.
33
34
*/
35
36
#include "libtorrent/session_handle.hpp"
37
#include "libtorrent/aux_/session_impl.hpp"
38
#include "libtorrent/aux_/session_call.hpp"
39
#include "libtorrent/aux_/throw.hpp"
40
#include "libtorrent/aux_/path.hpp"
41
#include "libtorrent/torrent.hpp"
42
#include "libtorrent/hasher.hpp"
43
#include "libtorrent/peer_class.hpp"
44
#include "libtorrent/peer_class_type_filter.hpp"
45
#include "libtorrent/aux_/scope_end.hpp"
46
47
#if TORRENT_ABI_VERSION == 1
48
#include "libtorrent/read_resume_data.hpp"
49
#include "libtorrent/magnet_uri.hpp"
50
#endif
51
52
using libtorrent::aux::session_impl;
53
54
namespace libtorrent {
55
56
  constexpr peer_class_t session_handle::global_peer_class_id;
57
  constexpr peer_class_t session_handle::tcp_peer_class_id;
58
  constexpr peer_class_t session_handle::local_peer_class_id;
59
60
  constexpr save_state_flags_t session_handle::save_settings;
61
#if TORRENT_ABI_VERSION <= 2
62
  constexpr save_state_flags_t session_handle::save_dht_settings TORRENT_DEPRECATED;
63
#endif
64
  constexpr save_state_flags_t session_handle::save_dht_state;
65
#if TORRENT_ABI_VERSION == 1
66
  constexpr save_state_flags_t session_handle::save_encryption_settings;
67
  constexpr save_state_flags_t session_handle::save_as_map TORRENT_DEPRECATED_ENUM;
68
  constexpr save_state_flags_t session_handle::save_proxy TORRENT_DEPRECATED_ENUM;
69
  constexpr save_state_flags_t session_handle::save_i2p_proxy TORRENT_DEPRECATED_ENUM;
70
  constexpr save_state_flags_t session_handle::save_dht_proxy TORRENT_DEPRECATED_ENUM;
71
  constexpr save_state_flags_t session_handle::save_peer_proxy TORRENT_DEPRECATED_ENUM;
72
  constexpr save_state_flags_t session_handle::save_web_proxy TORRENT_DEPRECATED_ENUM;
73
  constexpr save_state_flags_t session_handle::save_tracker_proxy TORRENT_DEPRECATED_ENUM;
74
#endif
75
  constexpr save_state_flags_t session_handle::save_extension_state;
76
  constexpr save_state_flags_t session_handle::save_ip_filter;
77
78
#if TORRENT_ABI_VERSION <= 2
79
  constexpr session_flags_t session_handle::add_default_plugins;
80
#endif
81
#if TORRENT_ABI_VERSION == 1
82
  constexpr session_flags_t session_handle::start_default_features;
83
#endif
84
  constexpr session_flags_t session_handle::paused;
85
86
  constexpr remove_flags_t session_handle::delete_files;
87
  constexpr remove_flags_t session_handle::delete_partfile;
88
89
  constexpr reopen_network_flags_t session_handle::reopen_map_ports;
90
91
  template <typename Fun, typename... Args>
92
  void session_handle::async_call(Fun f, Args&&... a) const
93
1.77k
  {
94
1.77k
    std::shared_ptr<session_impl> s = m_impl.lock();
95
1.77k
    if (!s) aux::throw_ex<system_error>(errors::invalid_session_handle);
96
1.77k
    dispatch(s->get_context(), std::bind([s, f](auto&&... args) mutable
97
1.77k
    {
98
1.77k
#ifndef BOOST_NO_EXCEPTIONS
99
1.77k
      try {
100
1.77k
#endif
101
1.77k
        (s.get()->*f)(std::forward<Args>(args)...);
102
1.77k
#ifndef BOOST_NO_EXCEPTIONS
103
1.77k
      } catch (system_error const& e) {
104
0
        s->alerts().emplace_alert<session_error_alert>(e.code(), e.what());
105
0
      } catch (std::exception const& e) {
106
0
        s->alerts().emplace_alert<session_error_alert>(error_code(), e.what());
107
0
      } catch (...) {
108
0
        s->alerts().emplace_alert<session_error_alert>(error_code(), "unknown error");
109
0
      }
110
1.77k
#endif
111
1.77k
    }, std::forward<Args>(a)...));
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNS_5flags13bitfield_flagIjNS_16status_flags_tagEvEEEJRKS7_EEEvT_DpOT0_ENUlDpOT_E_clIJRS7_EEEDaSI_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvvEJEEEvT_DpOT0_ENUlDpOT_E_clIJEEEDaSC_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvONS_3dht9dht_stateEEJS5_EEEvT_DpOT0_ENUlDpOT_E_clIJRS5_EEEDaSF_
_ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvPNS_18add_torrent_paramsEEJRS5_EEEvT_DpOT0_ENUlDpOT_E_clIJS8_EEEDaSF_
Line
Count
Source
97
1.77k
    {
98
1.77k
#ifndef BOOST_NO_EXCEPTIONS
99
1.77k
      try {
100
1.77k
#endif
101
1.77k
        (s.get()->*f)(std::forward<Args>(args)...);
102
1.77k
#ifndef BOOST_NO_EXCEPTIONS
103
1.77k
      } catch (system_error const& e) {
104
0
        s->alerts().emplace_alert<session_error_alert>(e.code(), e.what());
105
0
      } catch (std::exception const& e) {
106
0
        s->alerts().emplace_alert<session_error_alert>(error_code(), e.what());
107
0
      } catch (...) {
108
0
        s->alerts().emplace_alert<session_error_alert>(error_code(), "unknown error");
109
0
      }
110
1.77k
#endif
111
1.77k
    }, std::forward<Args>(a)...));
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNSt3__18functionIFvRKNS_8digest32ILl160EEERNS4_6vectorIcNS4_9allocatorIcEEEERN5boost6system10error_codeEEEEEJRSK_EEEvT_DpOT0_ENUlDpOT_E_clIJSN_EEEDaSU_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvRKNS_3dht12dht_settingsEEJS7_EEEvT_DpOT0_ENUlDpOT_E_clIJRS5_EEEDaSG_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNSt3__18functionIFNS4_10unique_ptrINS_3dht21dht_storage_interfaceENS4_14default_deleteIS8_EEEERKNS_18settings_interfaceEEEEEJRSG_EEEvT_DpOT0_ENUlDpOT_E_clIJSJ_EEEDaSQ_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvRKNSt3__14pairINS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEiEEEJSE_EEEvT_DpOT0_ENUlDpOT_E_clIJRSC_EEEDaSN_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvRKNS_8digest32ILl160EEEEJS7_EEEvT_DpOT0_ENUlDpOT_E_clIJRS5_EEEDaSG_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNSt3__15arrayIcLm32EEENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEJRS6_RSC_EEEvT_DpOT0_ENUlDpOT_E_clIJSF_SG_EEEDaSN_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvRKNS_5entryENS_8digest32ILl160EEEEJRS4_RKS8_EEEvT_DpOT0_ENUlDpOT_E_clIJSB_RS8_EEEDaSK_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNSt3__15arrayIcLm32EEENS4_8functionIFvRNS_5entryERNS5_IcLm64EEERlRKNS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEEESI_EJRS6_RSM_RSI_EEEvT_DpOT0_ENUlDpOT_E_clIJSP_SQ_SR_EEEDaSY_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvRKNS_8digest32ILl160EEEiNS_5flags13bitfield_flagIhNS_3dht21dht_announce_flag_tagEvEEEJS7_RiRKSC_EEEvT_DpOT0_ENUlDpOT_E_clIJRS5_SF_RSC_EEEDaSO_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvRKN5boost4asio2ip14basic_endpointINS6_3udpEEERKNS_8digest32ILl160EEEEJSB_SF_EEEvT_DpOT0_ENUlDpOT_E_clIJRS9_RSD_EEEDaSO_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvRKN5boost4asio2ip14basic_endpointINS6_3udpEEERNS_5entryENS_13client_data_tEEJSB_SD_RSE_EEEvT_DpOT0_ENUlDpOT_E_clIJRS9_SD_SH_EEEDaSO_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvRKNS_5entryEEJS6_EEEvT_DpOT0_ENUlDpOT_E_clIJRS4_EEEDaSF_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNSt3__18functionIFNS4_10shared_ptrINS_14torrent_pluginEEERKNS_14torrent_handleENS_13client_data_tEEEEEJRSE_EEEvT_DpOT0_ENUlDpOT_E_clIJSH_EEEDaSO_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNSt3__110shared_ptrINS_6pluginEEEEJRS7_EEEvT_DpOT0_ENUlDpOT_E_clIJSA_EEEDaSH_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNSt3__110shared_ptrINS_9ip_filterEEEEJS7_EEEvT_DpOT0_ENUlDpOT_E_clIJRS7_EEEDaSG_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvRKNS_11port_filterEEJS6_EEEvT_DpOT0_ENUlDpOT_E_clIJRS4_EEEDaSF_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvRKNS_9ip_filterEEJS6_EEEvT_DpOT0_ENUlDpOT_E_clIJRS4_EEEDaSF_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNS_22peer_class_type_filterEEJRKS4_EEEvT_DpOT0_ENUlDpOT_E_clIJRS4_EEEDaSF_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNS2_14strong_typedefIjNS_14peer_class_tagEvEEEJRS6_EEEvT_DpOT0_ENUlDpOT_E_clIJS9_EEEDaSG_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNS2_14strong_typedefIjNS_14peer_class_tagEvEERKNS_15peer_class_infoEEJRS6_S9_EEEvT_DpOT0_ENUlDpOT_E_clIJSC_RS7_EEEDaSJ_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvRKNS_14torrent_handleENS_5flags13bitfield_flagIhNS_16remove_flags_tagEvEEEJS6_RKSA_EEEvT_DpOT0_ENUlDpOT_E_clIJRS4_RSA_EEEDaSL_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNSt3__110shared_ptrINS_13settings_packEEEEJRS7_EEEvT_DpOT0_ENUlDpOT_E_clIJSA_EEEDaSH_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFviEJRiEEEvT_DpOT0_ENUlDpOT_E_clIJS6_EEEDaSD_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNS2_14strong_typedefIiNS_16port_mapping_tagEvEEEJRS6_EEEvT_DpOT0_ENUlDpOT_E_clIJS9_EEEDaSG_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle10async_callIMNS_3aux12session_implEFvNS_5flags13bitfield_flagIhNS_24reopen_network_flags_tagEvEEEJRKS7_EEEvT_DpOT0_ENUlDpOT_E_clIJRS7_EEEDaSI_
112
1.77k
  }
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void>), libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void> const&>(void (libtorrent::aux::session_impl::*)(libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void>), libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void> const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)()>(void (libtorrent::aux::session_impl::*)()) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::dht::dht_state&&), libtorrent::dht::dht_state>(void (libtorrent::aux::session_impl::*)(libtorrent::dht::dht_state&&), libtorrent::dht::dht_state&&) const
void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::add_torrent_params*), libtorrent::add_torrent_params*&>(void (libtorrent::aux::session_impl::*)(libtorrent::add_torrent_params*), libtorrent::add_torrent_params*&) const
Line
Count
Source
93
1.77k
  {
94
1.77k
    std::shared_ptr<session_impl> s = m_impl.lock();
95
1.77k
    if (!s) aux::throw_ex<system_error>(errors::invalid_session_handle);
96
1.77k
    dispatch(s->get_context(), std::bind([s, f](auto&&... args) mutable
97
1.77k
    {
98
1.77k
#ifndef BOOST_NO_EXCEPTIONS
99
1.77k
      try {
100
1.77k
#endif
101
1.77k
        (s.get()->*f)(std::forward<Args>(args)...);
102
1.77k
#ifndef BOOST_NO_EXCEPTIONS
103
1.77k
      } catch (system_error const& e) {
104
1.77k
        s->alerts().emplace_alert<session_error_alert>(e.code(), e.what());
105
1.77k
      } catch (std::exception const& e) {
106
1.77k
        s->alerts().emplace_alert<session_error_alert>(error_code(), e.what());
107
1.77k
      } catch (...) {
108
1.77k
        s->alerts().emplace_alert<session_error_alert>(error_code(), "unknown error");
109
1.77k
      }
110
1.77k
#endif
111
1.77k
    }, std::forward<Args>(a)...));
112
1.77k
  }
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(std::__1::function<void (libtorrent::digest32<160l> const&, std::__1::vector<char, std::__1::allocator<char> >&, boost::system::error_code&)>), std::__1::function<void (libtorrent::digest32<160l> const&, std::__1::vector<char, std::__1::allocator<char> >&, boost::system::error_code&)>&>(void (libtorrent::aux::session_impl::*)(std::__1::function<void (libtorrent::digest32<160l> const&, std::__1::vector<char, std::__1::allocator<char> >&, boost::system::error_code&)>), std::__1::function<void (libtorrent::digest32<160l> const&, std::__1::vector<char, std::__1::allocator<char> >&, boost::system::error_code&)>&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::dht::dht_settings const&), libtorrent::dht::dht_settings const&>(void (libtorrent::aux::session_impl::*)(libtorrent::dht::dht_settings const&), libtorrent::dht::dht_settings const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(std::__1::function<std::__1::unique_ptr<libtorrent::dht::dht_storage_interface, std::__1::default_delete<libtorrent::dht::dht_storage_interface> > (libtorrent::settings_interface const&)>), std::__1::function<std::__1::unique_ptr<libtorrent::dht::dht_storage_interface, std::__1::default_delete<libtorrent::dht::dht_storage_interface> > (libtorrent::settings_interface const&)>&>(void (libtorrent::aux::session_impl::*)(std::__1::function<std::__1::unique_ptr<libtorrent::dht::dht_storage_interface, std::__1::default_delete<libtorrent::dht::dht_storage_interface> > (libtorrent::settings_interface const&)>), std::__1::function<std::__1::unique_ptr<libtorrent::dht::dht_storage_interface, std::__1::default_delete<libtorrent::dht::dht_storage_interface> > (libtorrent::settings_interface const&)>&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int> const&), std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int> const&>(void (libtorrent::aux::session_impl::*)(std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int> const&), std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int> const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::digest32<160l> const&), libtorrent::digest32<160l> const&>(void (libtorrent::aux::session_impl::*)(libtorrent::digest32<160l> const&), libtorrent::digest32<160l> const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(std::__1::array<char, 32ul>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >), std::__1::array<char, 32ul>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(void (libtorrent::aux::session_impl::*)(std::__1::array<char, 32ul>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >), std::__1::array<char, 32ul>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::entry const&, libtorrent::digest32<160l>), libtorrent::entry&, libtorrent::digest32<160l> const&>(void (libtorrent::aux::session_impl::*)(libtorrent::entry const&, libtorrent::digest32<160l>), libtorrent::entry&, libtorrent::digest32<160l> const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(std::__1::array<char, 32ul>, std::__1::function<void (libtorrent::entry&, std::__1::array<char, 64ul>&, long&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >), std::__1::array<char, 32ul>&, std::__1::function<void (libtorrent::entry&, std::__1::array<char, 64ul>&, long&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(void (libtorrent::aux::session_impl::*)(std::__1::array<char, 32ul>, std::__1::function<void (libtorrent::entry&, std::__1::array<char, 64ul>&, long&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >), std::__1::array<char, 32ul>&, std::__1::function<void (libtorrent::entry&, std::__1::array<char, 64ul>&, long&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::digest32<160l> const&, int, libtorrent::flags::bitfield_flag<unsigned char, libtorrent::dht::dht_announce_flag_tag, void>), libtorrent::digest32<160l> const&, int&, libtorrent::flags::bitfield_flag<unsigned char, libtorrent::dht::dht_announce_flag_tag, void> const&>(void (libtorrent::aux::session_impl::*)(libtorrent::digest32<160l> const&, int, libtorrent::flags::bitfield_flag<unsigned char, libtorrent::dht::dht_announce_flag_tag, void>), libtorrent::digest32<160l> const&, int&, libtorrent::flags::bitfield_flag<unsigned char, libtorrent::dht::dht_announce_flag_tag, void> const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(boost::asio::ip::basic_endpoint<boost::asio::ip::udp> const&, libtorrent::digest32<160l> const&), boost::asio::ip::basic_endpoint<boost::asio::ip::udp> const&, libtorrent::digest32<160l> const&>(void (libtorrent::aux::session_impl::*)(boost::asio::ip::basic_endpoint<boost::asio::ip::udp> const&, libtorrent::digest32<160l> const&), boost::asio::ip::basic_endpoint<boost::asio::ip::udp> const&, libtorrent::digest32<160l> const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(boost::asio::ip::basic_endpoint<boost::asio::ip::udp> const&, libtorrent::entry&, libtorrent::client_data_t), boost::asio::ip::basic_endpoint<boost::asio::ip::udp> const&, libtorrent::entry&, libtorrent::client_data_t&>(void (libtorrent::aux::session_impl::*)(boost::asio::ip::basic_endpoint<boost::asio::ip::udp> const&, libtorrent::entry&, libtorrent::client_data_t), boost::asio::ip::basic_endpoint<boost::asio::ip::udp> const&, libtorrent::entry&, libtorrent::client_data_t&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::entry const&), libtorrent::entry const&>(void (libtorrent::aux::session_impl::*)(libtorrent::entry const&), libtorrent::entry const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(std::__1::function<std::__1::shared_ptr<libtorrent::torrent_plugin> (libtorrent::torrent_handle const&, libtorrent::client_data_t)>), std::__1::function<std::__1::shared_ptr<libtorrent::torrent_plugin> (libtorrent::torrent_handle const&, libtorrent::client_data_t)>&>(void (libtorrent::aux::session_impl::*)(std::__1::function<std::__1::shared_ptr<libtorrent::torrent_plugin> (libtorrent::torrent_handle const&, libtorrent::client_data_t)>), std::__1::function<std::__1::shared_ptr<libtorrent::torrent_plugin> (libtorrent::torrent_handle const&, libtorrent::client_data_t)>&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(std::__1::shared_ptr<libtorrent::plugin>), std::__1::shared_ptr<libtorrent::plugin>&>(void (libtorrent::aux::session_impl::*)(std::__1::shared_ptr<libtorrent::plugin>), std::__1::shared_ptr<libtorrent::plugin>&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(std::__1::shared_ptr<libtorrent::ip_filter>), std::__1::shared_ptr<libtorrent::ip_filter> >(void (libtorrent::aux::session_impl::*)(std::__1::shared_ptr<libtorrent::ip_filter>), std::__1::shared_ptr<libtorrent::ip_filter>&&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::port_filter const&), libtorrent::port_filter const&>(void (libtorrent::aux::session_impl::*)(libtorrent::port_filter const&), libtorrent::port_filter const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::ip_filter const&), libtorrent::ip_filter const&>(void (libtorrent::aux::session_impl::*)(libtorrent::ip_filter const&), libtorrent::ip_filter const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::peer_class_type_filter), libtorrent::peer_class_type_filter const&>(void (libtorrent::aux::session_impl::*)(libtorrent::peer_class_type_filter), libtorrent::peer_class_type_filter const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>), libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>&>(void (libtorrent::aux::session_impl::*)(libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>), libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>, libtorrent::peer_class_info const&), libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>&, libtorrent::peer_class_info const&>(void (libtorrent::aux::session_impl::*)(libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>, libtorrent::peer_class_info const&), libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>&, libtorrent::peer_class_info const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::torrent_handle const&, libtorrent::flags::bitfield_flag<unsigned char, libtorrent::remove_flags_tag, void>), libtorrent::torrent_handle const&, libtorrent::flags::bitfield_flag<unsigned char, libtorrent::remove_flags_tag, void> const&>(void (libtorrent::aux::session_impl::*)(libtorrent::torrent_handle const&, libtorrent::flags::bitfield_flag<unsigned char, libtorrent::remove_flags_tag, void>), libtorrent::torrent_handle const&, libtorrent::flags::bitfield_flag<unsigned char, libtorrent::remove_flags_tag, void> const&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(std::__1::shared_ptr<libtorrent::settings_pack>), std::__1::shared_ptr<libtorrent::settings_pack>&>(void (libtorrent::aux::session_impl::*)(std::__1::shared_ptr<libtorrent::settings_pack>), std::__1::shared_ptr<libtorrent::settings_pack>&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(int), int&>(void (libtorrent::aux::session_impl::*)(int), int&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::aux::strong_typedef<int, libtorrent::port_mapping_tag, void>), libtorrent::aux::strong_typedef<int, libtorrent::port_mapping_tag, void>&>(void (libtorrent::aux::session_impl::*)(libtorrent::aux::strong_typedef<int, libtorrent::port_mapping_tag, void>), libtorrent::aux::strong_typedef<int, libtorrent::port_mapping_tag, void>&) const
Unexecuted instantiation: void libtorrent::session_handle::async_call<void (libtorrent::aux::session_impl::*)(libtorrent::flags::bitfield_flag<unsigned char, libtorrent::reopen_network_flags_tag, void>), libtorrent::flags::bitfield_flag<unsigned char, libtorrent::reopen_network_flags_tag, void> const&>(void (libtorrent::aux::session_impl::*)(libtorrent::flags::bitfield_flag<unsigned char, libtorrent::reopen_network_flags_tag, void>), libtorrent::flags::bitfield_flag<unsigned char, libtorrent::reopen_network_flags_tag, void> const&) const
113
114
  template<typename Fun, typename... Args>
115
  void session_handle::sync_call(Fun f, Args&&... a) const
116
0
  {
117
0
    std::shared_ptr<session_impl> s = m_impl.lock();
118
0
    if (!s) aux::throw_ex<system_error>(errors::invalid_session_handle);
119
120
    // this is the flag to indicate the call has completed
121
    // capture them by pointer to allow everything to be captured by value
122
    // and simplify the capture expression
123
0
    bool done = false;
124
125
0
    std::exception_ptr ex;
126
0
    dispatch(s->get_context(), std::bind([s, f, &done, &ex](auto&&... args) mutable
127
0
    {
128
0
#ifndef BOOST_NO_EXCEPTIONS
129
0
      try {
130
0
#endif
131
0
        (s.get()->*f)(std::forward<Args>(args)...);
132
0
#ifndef BOOST_NO_EXCEPTIONS
133
0
      } catch (...) {
134
0
        ex = std::current_exception();
135
0
      }
136
0
#endif
137
0
      std::unique_lock<std::mutex> l(s->mut);
138
0
      done = true;
139
0
      s->cond.notify_all();
140
0
    }, std::forward<Args>(a)...));
Unexecuted instantiation: _ZZNK10libtorrent14session_handle9sync_callIMNS_3aux12session_implEKFvPNS_5entryENS_5flags13bitfield_flagIjNS_20save_state_flags_tagEvEEEJRS5_RKS9_EEEvT_DpOT0_ENUlDpOT_E_clIJSC_RS9_EEEDaSL_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle9sync_callIMNS_3aux12session_implEFvPKNS_12bdecode_nodeENS_5flags13bitfield_flagIjNS_20save_state_flags_tagEvEEEJS6_RKSA_EEEvT_DpOT0_ENUlDpOT_E_clIJRS6_RSA_EEEDaSL_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle9sync_callIMNS_3aux12session_implEKFvPNSt3__16vectorINS_14torrent_statusENS4_9allocatorIS6_EEEERKNS4_8functionIFbRKS6_EEENS_5flags13bitfield_flagIjNS_16status_flags_tagEvEEEJSA_SH_RKSL_EEEvT_DpOT0_ENUlDpOT_E_clIJRSA_RSF_RSL_EEEDaSW_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle9sync_callIMNS_3aux12session_implEKFvPNSt3__16vectorINS_14torrent_statusENS4_9allocatorIS6_EEEERKNS4_8functionIFbRKS6_EEENS_5flags13bitfield_flagIjNS_16status_flags_tagEvEEEJRSA_SH_RKSL_EEEvT_DpOT0_ENUlDpOT_E_clIJSO_RSF_RSL_EEEDaSX_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle9sync_callIMNS_3aux12session_implEKFvPNSt3__16vectorINS_14torrent_statusENS4_9allocatorIS6_EEEENS_5flags13bitfield_flagIjNS_16status_flags_tagEvEEEJRSA_RKSE_EEEvT_DpOT0_ENUlDpOT_E_clIJSH_RSE_EEEDaSQ_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle9sync_callIMNS_3aux12session_implEFvPKNS_12bdecode_nodeENS_5flags13bitfield_flagIjNS_20save_state_flags_tagEvEEEJPS4_RKSA_EEEvT_DpOT0_ENUlDpOT_E_clIJRSD_RSA_EEEDaSM_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle9sync_callIMNS_3aux12session_implEKFvPNS_5entryENS_5flags13bitfield_flagIjNS_20save_state_flags_tagEvEEEJRS5_S9_EEEvT_DpOT0_ENUlDpOT_E_clIJSC_RS9_EEEDaSJ_
141
142
0
    aux::torrent_wait(done, *s);
143
0
    if (ex) std::rethrow_exception(ex);
144
0
  }
Unexecuted instantiation: void libtorrent::session_handle::sync_call<void (libtorrent::aux::session_impl::*)(libtorrent::entry*, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void>) const, libtorrent::entry*&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void> const&>(void (libtorrent::aux::session_impl::*)(libtorrent::entry*, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void>) const, libtorrent::entry*&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void> const&) const
Unexecuted instantiation: void libtorrent::session_handle::sync_call<void (libtorrent::aux::session_impl::*)(libtorrent::bdecode_node const*, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void>), libtorrent::bdecode_node const*, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void> const&>(void (libtorrent::aux::session_impl::*)(libtorrent::bdecode_node const*, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void>), libtorrent::bdecode_node const*&&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void> const&) const
Unexecuted instantiation: void libtorrent::session_handle::sync_call<void (libtorrent::aux::session_impl::*)(std::__1::vector<libtorrent::torrent_status, std::__1::allocator<libtorrent::torrent_status> >*, std::__1::function<bool (libtorrent::torrent_status const&)> const&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void>) const, std::__1::vector<libtorrent::torrent_status, std::__1::allocator<libtorrent::torrent_status> >*, std::__1::function<bool (libtorrent::torrent_status const&)> const&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void> const&>(void (libtorrent::aux::session_impl::*)(std::__1::vector<libtorrent::torrent_status, std::__1::allocator<libtorrent::torrent_status> >*, std::__1::function<bool (libtorrent::torrent_status const&)> const&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void>) const, std::__1::vector<libtorrent::torrent_status, std::__1::allocator<libtorrent::torrent_status> >*&&, std::__1::function<bool (libtorrent::torrent_status const&)> const&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void> const&) const
Unexecuted instantiation: void libtorrent::session_handle::sync_call<void (libtorrent::aux::session_impl::*)(std::__1::vector<libtorrent::torrent_status, std::__1::allocator<libtorrent::torrent_status> >*, std::__1::function<bool (libtorrent::torrent_status const&)> const&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void>) const, std::__1::vector<libtorrent::torrent_status, std::__1::allocator<libtorrent::torrent_status> >*&, std::__1::function<bool (libtorrent::torrent_status const&)> const&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void> const&>(void (libtorrent::aux::session_impl::*)(std::__1::vector<libtorrent::torrent_status, std::__1::allocator<libtorrent::torrent_status> >*, std::__1::function<bool (libtorrent::torrent_status const&)> const&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void>) const, std::__1::vector<libtorrent::torrent_status, std::__1::allocator<libtorrent::torrent_status> >*&, std::__1::function<bool (libtorrent::torrent_status const&)> const&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void> const&) const
Unexecuted instantiation: void libtorrent::session_handle::sync_call<void (libtorrent::aux::session_impl::*)(std::__1::vector<libtorrent::torrent_status, std::__1::allocator<libtorrent::torrent_status> >*, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void>) const, std::__1::vector<libtorrent::torrent_status, std::__1::allocator<libtorrent::torrent_status> >*&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void> const&>(void (libtorrent::aux::session_impl::*)(std::__1::vector<libtorrent::torrent_status, std::__1::allocator<libtorrent::torrent_status> >*, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void>) const, std::__1::vector<libtorrent::torrent_status, std::__1::allocator<libtorrent::torrent_status> >*&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::status_flags_tag, void> const&) const
Unexecuted instantiation: void libtorrent::session_handle::sync_call<void (libtorrent::aux::session_impl::*)(libtorrent::bdecode_node const*, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void>), libtorrent::bdecode_node*, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void> const&>(void (libtorrent::aux::session_impl::*)(libtorrent::bdecode_node const*, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void>), libtorrent::bdecode_node*&&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void> const&) const
Unexecuted instantiation: void libtorrent::session_handle::sync_call<void (libtorrent::aux::session_impl::*)(libtorrent::entry*, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void>) const, libtorrent::entry*&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void> >(void (libtorrent::aux::session_impl::*)(libtorrent::entry*, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void>) const, libtorrent::entry*&, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void>&&) const
145
146
  template<typename Ret, typename Fun, typename... Args>
147
  Ret session_handle::sync_call_ret(Fun f, Args&&... a) const
148
1
  {
149
1
    std::shared_ptr<session_impl> s = m_impl.lock();
150
1
    if (!s) aux::throw_ex<system_error>(errors::invalid_session_handle);
151
152
    // this is the flag to indicate the call has completed
153
    // capture them by pointer to allow everything to be captured by value
154
    // and simplify the capture expression
155
1
    bool done = false;
156
1
    Ret r;
157
1
    std::exception_ptr ex;
158
1
    dispatch(s->get_context(), std::bind([s, f, &r, &done, &ex](auto&&... args) mutable
159
1
    {
160
1
#ifndef BOOST_NO_EXCEPTIONS
161
1
      try {
162
1
#endif
163
1
        r = (s.get()->*f)(std::forward<Args>(args)...);
164
1
#ifndef BOOST_NO_EXCEPTIONS
165
1
      } catch (...) {
166
0
        ex = std::current_exception();
167
0
      }
168
1
#endif
169
1
      std::unique_lock<std::mutex> l(s->mut);
170
1
      done = true;
171
1
      s->cond.notify_all();
172
1
    }, std::forward<Args>(a)...));
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINS_14session_paramsEMNS_3aux12session_implEKFS2_NS_5flags13bitfield_flagIjNS_20save_state_flags_tagEvEEEJRKS8_EEET_T0_DpOT1_ENUlDpOT_E_clIJRS8_EEEDaSK_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINS_14torrent_handleEMNS_3aux12session_implEFS2_RKNS_11info_hash_tEEJS5_EEET_T0_DpOT1_ENUlDpOT_E_clIJRS5_EEEDaSH_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINSt3__16vectorINS_14torrent_handleENS2_9allocatorIS4_EEEEMNS_3aux12session_implEKFS7_vEJEEET_T0_DpOT1_ENUlDpOT_E_clIJEEEDaSJ_
_ZZNK10libtorrent14session_handle13sync_call_retINS_14torrent_handleEMNS_3aux12session_implEFS2_ONS_18add_torrent_paramsERN5boost6system10error_codeEEJS5_NSt3__117reference_wrapperIS9_EEEEET_T0_DpOT1_ENUlDpOT_E_clIJRS5_SA_EEEDaSN_
Line
Count
Source
159
1
    {
160
1
#ifndef BOOST_NO_EXCEPTIONS
161
1
      try {
162
1
#endif
163
1
        r = (s.get()->*f)(std::forward<Args>(args)...);
164
1
#ifndef BOOST_NO_EXCEPTIONS
165
1
      } catch (...) {
166
0
        ex = std::current_exception();
167
0
      }
168
1
#endif
169
1
      std::unique_lock<std::mutex> l(s->mut);
170
1
      done = true;
171
1
      s->cond.notify_all();
172
1
    }, std::forward<Args>(a)...));
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retIbMNS_3aux12session_implEKFbvEJEEET_T0_DpOT1_ENUlDpOT_E_clIJEEEDaSD_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINS_14session_statusEMNS_3aux12session_implEKFS2_vEJEEET_T0_DpOT1_ENUlDpOT_E_clIJEEEDaSE_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINS_3dht12dht_settingsEMNS_3aux12session_implEKFS3_vEJEEET_T0_DpOT1_ENUlDpOT_E_clIJEEEDaSF_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINS_5entryEMNS_3aux12session_implEKFS2_vEJEEET_T0_DpOT1_ENUlDpOT_E_clIJEEEDaSE_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINS_9ip_filterEMNS_3aux12session_implEFRKS2_vEJEEET_T0_DpOT1_ENUlDpOT_E_clIJEEEDaSG_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINS_8digest32ILl160EEEMNS_3aux12session_implEKFS3_vEJEEET_T0_DpOT1_ENUlDpOT_E_clIJEEEDaSF_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retItMNS_3aux12session_implEKFtvEJEEET_T0_DpOT1_ENUlDpOT_E_clIJEEEDaSD_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINS_9ip_filterEMNS_3aux12session_implEKFRKS2_vEJEEET_T0_DpOT1_ENUlDpOT_E_clIJEEEDaSG_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINS_22peer_class_type_filterEMNS_3aux12session_implEFS2_vEJEEET_T0_DpOT1_ENUlDpOT_E_clIJEEEDaSE_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINS_3aux14strong_typedefIjNS_14peer_class_tagEvEEMNS2_12session_implEFS5_PKcEJRS8_EEET_T0_DpOT1_ENUlDpOT_E_clIJSB_EEEDaSJ_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINS_15peer_class_infoEMNS_3aux12session_implEKFS2_NS3_14strong_typedefIjNS_14peer_class_tagEvEEEJRS7_EEET_T0_DpOT1_ENUlDpOT_E_clIJSA_EEEDaSI_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINS_13settings_packEMNS_3aux12session_implEKFS2_vEJEEET_T0_DpOT1_ENUlDpOT_E_clIJEEEDaSE_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retIiMNS_3aux12session_implEKFivEJEEET_T0_DpOT1_ENUlDpOT_E_clIJEEEDaSD_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retImMNS_3aux12session_implEFmmEJRmEEET_T0_DpOT1_ENUlDpOT_E_clIJS6_EEEDaSE_
Unexecuted instantiation: _ZZNK10libtorrent14session_handle13sync_call_retINSt3__16vectorINS_3aux14strong_typedefIiNS_16port_mapping_tagEvEENS2_9allocatorIS7_EEEEMNS4_12session_implEFSA_NS_16portmap_protocolEiiEJRKSC_RiSH_EEET_T0_DpOT1_ENUlDpOT_E_clIJRSC_SH_SH_EEEDaSP_
173
174
1
    aux::torrent_wait(done, *s);
175
1
    if (ex) std::rethrow_exception(ex);
176
1
    return r;
177
1
  }
Unexecuted instantiation: libtorrent::session_params libtorrent::session_handle::sync_call_ret<libtorrent::session_params, libtorrent::session_params (libtorrent::aux::session_impl::*)(libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void>) const, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void> const&>(libtorrent::session_params (libtorrent::aux::session_impl::*)(libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void>) const, libtorrent::flags::bitfield_flag<unsigned int, libtorrent::save_state_flags_tag, void> const&) const
Unexecuted instantiation: libtorrent::torrent_handle libtorrent::session_handle::sync_call_ret<libtorrent::torrent_handle, libtorrent::torrent_handle (libtorrent::aux::session_impl::*)(libtorrent::info_hash_t const&), libtorrent::info_hash_t>(libtorrent::torrent_handle (libtorrent::aux::session_impl::*)(libtorrent::info_hash_t const&), libtorrent::info_hash_t&&) const
Unexecuted instantiation: std::__1::vector<libtorrent::torrent_handle, std::__1::allocator<libtorrent::torrent_handle> > libtorrent::session_handle::sync_call_ret<std::__1::vector<libtorrent::torrent_handle, std::__1::allocator<libtorrent::torrent_handle> >, std::__1::vector<libtorrent::torrent_handle, std::__1::allocator<libtorrent::torrent_handle> > (libtorrent::aux::session_impl::*)() const>(std::__1::vector<libtorrent::torrent_handle, std::__1::allocator<libtorrent::torrent_handle> > (libtorrent::aux::session_impl::*)() const) const
libtorrent::torrent_handle libtorrent::session_handle::sync_call_ret<libtorrent::torrent_handle, libtorrent::torrent_handle (libtorrent::aux::session_impl::*)(libtorrent::add_torrent_params&&, boost::system::error_code&), libtorrent::add_torrent_params, std::__1::reference_wrapper<boost::system::error_code> >(libtorrent::torrent_handle (libtorrent::aux::session_impl::*)(libtorrent::add_torrent_params&&, boost::system::error_code&), libtorrent::add_torrent_params&&, std::__1::reference_wrapper<boost::system::error_code>&&) const
Line
Count
Source
148
1
  {
149
1
    std::shared_ptr<session_impl> s = m_impl.lock();
150
1
    if (!s) aux::throw_ex<system_error>(errors::invalid_session_handle);
151
152
    // this is the flag to indicate the call has completed
153
    // capture them by pointer to allow everything to be captured by value
154
    // and simplify the capture expression
155
1
    bool done = false;
156
1
    Ret r;
157
1
    std::exception_ptr ex;
158
1
    dispatch(s->get_context(), std::bind([s, f, &r, &done, &ex](auto&&... args) mutable
159
1
    {
160
1
#ifndef BOOST_NO_EXCEPTIONS
161
1
      try {
162
1
#endif
163
1
        r = (s.get()->*f)(std::forward<Args>(args)...);
164
1
#ifndef BOOST_NO_EXCEPTIONS
165
1
      } catch (...) {
166
1
        ex = std::current_exception();
167
1
      }
168
1
#endif
169
1
      std::unique_lock<std::mutex> l(s->mut);
170
1
      done = true;
171
1
      s->cond.notify_all();
172
1
    }, std::forward<Args>(a)...));
173
174
1
    aux::torrent_wait(done, *s);
175
1
    if (ex) std::rethrow_exception(ex);
176
1
    return r;
177
1
  }
Unexecuted instantiation: bool libtorrent::session_handle::sync_call_ret<bool, bool (libtorrent::aux::session_impl::*)() const>(bool (libtorrent::aux::session_impl::*)() const) const
Unexecuted instantiation: libtorrent::session_status libtorrent::session_handle::sync_call_ret<libtorrent::session_status, libtorrent::session_status (libtorrent::aux::session_impl::*)() const>(libtorrent::session_status (libtorrent::aux::session_impl::*)() const) const
Unexecuted instantiation: libtorrent::dht::dht_settings libtorrent::session_handle::sync_call_ret<libtorrent::dht::dht_settings, libtorrent::dht::dht_settings (libtorrent::aux::session_impl::*)() const>(libtorrent::dht::dht_settings (libtorrent::aux::session_impl::*)() const) const
Unexecuted instantiation: libtorrent::entry libtorrent::session_handle::sync_call_ret<libtorrent::entry, libtorrent::entry (libtorrent::aux::session_impl::*)() const>(libtorrent::entry (libtorrent::aux::session_impl::*)() const) const
Unexecuted instantiation: libtorrent::ip_filter libtorrent::session_handle::sync_call_ret<libtorrent::ip_filter, libtorrent::ip_filter const& (libtorrent::aux::session_impl::*)()>(libtorrent::ip_filter const& (libtorrent::aux::session_impl::*)()) const
Unexecuted instantiation: libtorrent::digest32<160l> libtorrent::session_handle::sync_call_ret<libtorrent::digest32<160l>, libtorrent::digest32<160l> (libtorrent::aux::session_impl::*)() const>(libtorrent::digest32<160l> (libtorrent::aux::session_impl::*)() const) const
Unexecuted instantiation: unsigned short libtorrent::session_handle::sync_call_ret<unsigned short, unsigned short (libtorrent::aux::session_impl::*)() const>(unsigned short (libtorrent::aux::session_impl::*)() const) const
Unexecuted instantiation: libtorrent::ip_filter libtorrent::session_handle::sync_call_ret<libtorrent::ip_filter, libtorrent::ip_filter const& (libtorrent::aux::session_impl::*)() const>(libtorrent::ip_filter const& (libtorrent::aux::session_impl::*)() const) const
Unexecuted instantiation: libtorrent::peer_class_type_filter libtorrent::session_handle::sync_call_ret<libtorrent::peer_class_type_filter, libtorrent::peer_class_type_filter (libtorrent::aux::session_impl::*)()>(libtorrent::peer_class_type_filter (libtorrent::aux::session_impl::*)()) const
Unexecuted instantiation: libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void> libtorrent::session_handle::sync_call_ret<libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>, libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void> (libtorrent::aux::session_impl::*)(char const*), char const*&>(libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void> (libtorrent::aux::session_impl::*)(char const*), char const*&) const
Unexecuted instantiation: libtorrent::peer_class_info libtorrent::session_handle::sync_call_ret<libtorrent::peer_class_info, libtorrent::peer_class_info (libtorrent::aux::session_impl::*)(libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>) const, libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>&>(libtorrent::peer_class_info (libtorrent::aux::session_impl::*)(libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>) const, libtorrent::aux::strong_typedef<unsigned int, libtorrent::peer_class_tag, void>&) const
Unexecuted instantiation: libtorrent::settings_pack libtorrent::session_handle::sync_call_ret<libtorrent::settings_pack, libtorrent::settings_pack (libtorrent::aux::session_impl::*)() const>(libtorrent::settings_pack (libtorrent::aux::session_impl::*)() const) const
Unexecuted instantiation: int libtorrent::session_handle::sync_call_ret<int, int (libtorrent::aux::session_impl::*)() const>(int (libtorrent::aux::session_impl::*)() const) const
Unexecuted instantiation: unsigned long libtorrent::session_handle::sync_call_ret<unsigned long, unsigned long (libtorrent::aux::session_impl::*)(unsigned long), unsigned long&>(unsigned long (libtorrent::aux::session_impl::*)(unsigned long), unsigned long&) const
Unexecuted instantiation: std::__1::vector<libtorrent::aux::strong_typedef<int, libtorrent::port_mapping_tag, void>, std::__1::allocator<libtorrent::aux::strong_typedef<int, libtorrent::port_mapping_tag, void> > > libtorrent::session_handle::sync_call_ret<std::__1::vector<libtorrent::aux::strong_typedef<int, libtorrent::port_mapping_tag, void>, std::__1::allocator<libtorrent::aux::strong_typedef<int, libtorrent::port_mapping_tag, void> > >, std::__1::vector<libtorrent::aux::strong_typedef<int, libtorrent::port_mapping_tag, void>, std::__1::allocator<libtorrent::aux::strong_typedef<int, libtorrent::port_mapping_tag, void> > > (libtorrent::aux::session_impl::*)(libtorrent::portmap_protocol, int, int), libtorrent::portmap_protocol const&, int&, int&>(std::__1::vector<libtorrent::aux::strong_typedef<int, libtorrent::port_mapping_tag, void>, std::__1::allocator<libtorrent::aux::strong_typedef<int, libtorrent::port_mapping_tag, void> > > (libtorrent::aux::session_impl::*)(libtorrent::portmap_protocol, int, int), libtorrent::portmap_protocol const&, int&, int&) const
178
179
#if TORRENT_ABI_VERSION <= 2
180
  void session_handle::save_state(entry& e, save_state_flags_t const flags) const
181
0
  {
182
0
    entry* ep = &e;
183
0
    sync_call(&session_impl::save_state, ep, flags);
184
0
  }
185
186
  void session_handle::load_state(bdecode_node const& e
187
    , save_state_flags_t const flags)
188
0
  {
189
    // this needs to be synchronized since the lifespan
190
    // of e is tied to the caller
191
0
    sync_call(&session_impl::load_state, &e, flags);
192
0
  }
193
#endif
194
195
  session_params session_handle::session_state(save_state_flags_t const flags) const
196
0
  {
197
0
    return sync_call_ret<session_params>(&session_impl::session_state, flags);
198
0
  }
199
200
  std::vector<torrent_status> session_handle::get_torrent_status(
201
    std::function<bool(torrent_status const&)> const& pred
202
    , status_flags_t const flags) const
203
0
  {
204
0
    std::vector<torrent_status> ret;
205
0
    sync_call(&session_impl::get_torrent_status, &ret, pred, flags);
206
0
    return ret;
207
0
  }
208
209
#if TORRENT_ABI_VERSION == 1
210
  void session_handle::get_torrent_status(std::vector<torrent_status>* ret
211
    , std::function<bool(torrent_status const&)> const& pred
212
    , status_flags_t const flags) const
213
0
  {
214
0
    sync_call(&session_impl::get_torrent_status, ret, pred, flags);
215
0
  }
216
#endif
217
218
  void session_handle::refresh_torrent_status(std::vector<torrent_status>* ret
219
    , status_flags_t const flags) const
220
0
  {
221
0
    sync_call(&session_impl::refresh_torrent_status, ret, flags);
222
0
  }
223
224
  void session_handle::post_torrent_updates(status_flags_t const flags)
225
0
  {
226
0
    async_call(&session_impl::post_torrent_updates, flags);
227
0
  }
228
229
  void session_handle::post_session_stats()
230
0
  {
231
0
    async_call(&session_impl::post_session_stats);
232
0
  }
233
234
  void session_handle::post_dht_stats()
235
0
  {
236
0
    async_call(&session_impl::post_dht_stats);
237
0
  }
238
239
  io_context& session_handle::get_context()
240
0
  {
241
0
    std::shared_ptr<session_impl> s = m_impl.lock();
242
0
    if (!s) aux::throw_ex<system_error>(errors::invalid_session_handle);
243
0
    return s->get_context();
244
0
  }
245
246
  void session_handle::set_dht_state(dht::dht_state const& st)
247
0
  {
248
0
#ifndef TORRENT_DISABLE_DHT
249
0
    async_call(&session_impl::set_dht_state, dht::dht_state(st));
250
#else
251
    TORRENT_UNUSED(st);
252
#endif
253
0
  }
254
255
  void session_handle::set_dht_state(dht::dht_state&& st)
256
0
  {
257
0
#ifndef TORRENT_DISABLE_DHT
258
0
    async_call(&session_impl::set_dht_state, std::move(st));
259
#else
260
    TORRENT_UNUSED(st);
261
#endif
262
0
  }
263
264
  torrent_handle session_handle::find_torrent(sha1_hash const& info_hash) const
265
0
  {
266
0
    return sync_call_ret<torrent_handle>(&session_impl::find_torrent_handle, info_hash_t(info_hash));
267
0
  }
268
269
  torrent_handle session_handle::find_torrent(sha256_hash const& info_hash) const
270
0
  {
271
0
    return sync_call_ret<torrent_handle>(&session_impl::find_torrent_handle, info_hash_t(info_hash));
272
0
  }
273
274
  std::vector<torrent_handle> session_handle::get_torrents() const
275
0
  {
276
0
    return sync_call_ret<std::vector<torrent_handle>>(&session_impl::get_torrents);
277
0
  }
278
279
#if TORRENT_ABI_VERSION == 1
280
namespace {
281
282
  void handle_backwards_compatible_resume_data(add_torrent_params& atp)
283
1.77k
  {
284
    // if there's no resume data set, there's nothing to do. It's either
285
    // using the previous API without resume data, or the resume data has
286
    // already been parsed out into the add_torrent_params struct.
287
1.77k
    if (atp.resume_data.empty()) return;
288
289
0
    error_code ec;
290
0
    add_torrent_params resume_data
291
0
      = read_resume_data(atp.resume_data, ec);
292
293
0
    resume_data.internal_resume_data_error = ec;
294
0
    if (ec) return;
295
296
    // now, merge resume_data into atp according to the merge flags
297
0
    if ((atp.flags & add_torrent_params::flag_use_resume_save_path)
298
0
      && !resume_data.save_path.empty())
299
0
    {
300
0
      atp.save_path = std::move(resume_data.save_path);
301
0
    }
302
303
0
    if (!atp.ti)
304
0
    {
305
0
      atp.ti = std::move(resume_data.ti);
306
0
    }
307
308
0
    if (!resume_data.trackers.empty())
309
0
    {
310
0
      atp.tracker_tiers.resize(atp.trackers.size(), 0);
311
0
      atp.trackers.insert(atp.trackers.end()
312
0
        , resume_data.trackers.begin()
313
0
        , resume_data.trackers.end());
314
0
      atp.tracker_tiers.insert(atp.tracker_tiers.end()
315
0
        , resume_data.tracker_tiers.begin()
316
0
        , resume_data.tracker_tiers.end());
317
0
      if (!(resume_data.flags & add_torrent_params::flag_merge_resume_trackers))
318
0
        atp.flags |= add_torrent_params::flag_override_trackers;
319
0
    }
320
321
0
    if (!resume_data.url_seeds.empty())
322
0
    {
323
0
      if (!(atp.flags & add_torrent_params::flag_merge_resume_http_seeds))
324
0
        atp.url_seeds.clear();
325
326
0
      atp.url_seeds.insert(atp.url_seeds.end()
327
0
        , resume_data.url_seeds.begin()
328
0
        , resume_data.url_seeds.end());
329
0
      if (!(atp.flags & add_torrent_params::flag_merge_resume_http_seeds))
330
0
        atp.flags |= add_torrent_params::flag_override_web_seeds;
331
0
    }
332
333
0
    if (!resume_data.http_seeds.empty())
334
0
    {
335
0
      if (!(atp.flags & add_torrent_params::flag_merge_resume_http_seeds))
336
0
        atp.http_seeds.clear();
337
338
0
      atp.http_seeds.insert(atp.http_seeds.end()
339
0
        , resume_data.http_seeds.begin()
340
0
        , resume_data.http_seeds.end());
341
0
      if (!(atp.flags & add_torrent_params::flag_merge_resume_http_seeds))
342
0
        atp.flags |= add_torrent_params::flag_override_web_seeds;
343
0
    }
344
345
0
    atp.total_uploaded = resume_data.total_uploaded;
346
0
    atp.total_downloaded = resume_data.total_downloaded;
347
0
    atp.num_complete = resume_data.num_complete;
348
0
    atp.num_incomplete = resume_data.num_incomplete;
349
0
    atp.num_downloaded = resume_data.num_downloaded;
350
0
    atp.active_time = resume_data.active_time;
351
0
    atp.finished_time = resume_data.finished_time;
352
0
    atp.seeding_time = resume_data.seeding_time;
353
354
0
    atp.last_seen_complete = resume_data.last_seen_complete;
355
0
    atp.last_upload = resume_data.last_upload;
356
0
    atp.last_download = resume_data.last_download;
357
0
    atp.url = resume_data.url;
358
359
0
    atp.added_time = resume_data.added_time;
360
0
    atp.completed_time = resume_data.completed_time;
361
362
0
    atp.peers.swap(resume_data.peers);
363
0
    atp.banned_peers.swap(resume_data.banned_peers);
364
365
0
    atp.unfinished_pieces.swap(resume_data.unfinished_pieces);
366
0
    atp.have_pieces.swap(resume_data.have_pieces);
367
0
    atp.verified_pieces.swap(resume_data.verified_pieces);
368
0
    atp.piece_priorities.swap(resume_data.piece_priorities);
369
370
0
    atp.renamed_files = std::move(resume_data.renamed_files);
371
372
0
    if (!(atp.flags & add_torrent_params::flag_override_resume_data))
373
0
    {
374
0
      atp.download_limit = resume_data.download_limit;
375
0
      atp.upload_limit = resume_data.upload_limit;
376
0
      atp.max_connections = resume_data.max_connections;
377
0
      atp.max_uploads = resume_data.max_uploads;
378
0
      atp.trackerid = resume_data.trackerid;
379
0
      if (!resume_data.file_priorities.empty())
380
0
        atp.file_priorities = resume_data.file_priorities;
381
382
0
      torrent_flags_t const mask =
383
0
        add_torrent_params::flag_seed_mode
384
0
        | add_torrent_params::flag_super_seeding
385
0
        | add_torrent_params::flag_auto_managed
386
0
        | add_torrent_params::flag_sequential_download
387
0
        | add_torrent_params::flag_paused;
388
389
0
      atp.flags &= ~mask;
390
0
      atp.flags |= resume_data.flags & mask;
391
0
    }
392
0
    else
393
0
    {
394
0
      if (atp.file_priorities.empty())
395
0
        atp.file_priorities = resume_data.file_priorities;
396
0
    }
397
398
0
    if (atp.info_hash.is_all_zeros()
399
0
      && string_begins_no_case("magnet:", atp.url.c_str()))
400
0
    {
401
0
      error_code err;
402
0
      parse_magnet_uri(atp.url, atp, err);
403
0
      if (!err) atp.url.clear();
404
0
    }
405
0
  }
406
407
} // anonymous namespace
408
409
#endif // TORRENT_ABI_VERSION
410
411
#ifndef BOOST_NO_EXCEPTIONS
412
  torrent_handle session_handle::add_torrent(add_torrent_params&& params)
413
1
  {
414
1
#ifndef BOOST_NO_EXCEPTIONS
415
1
    if (params.save_path.empty())
416
0
      aux::throw_ex<system_error>(error_code(errors::invalid_save_path));
417
#else
418
    TORRENT_ASSERT_PRECOND(!params.save_path.empty());
419
#endif
420
421
1
#if TORRENT_ABI_VERSION < 3
422
1
    if (!params.info_hashes.has_v1() && !params.info_hashes.has_v2() && !params.ti)
423
0
      params.info_hashes.v1 = params.info_hash;
424
1
#endif
425
426
    // the internal torrent object keeps and mutates state in the
427
    // torrent_info object. We can't let that leak back to the client
428
1
    if (params.ti)
429
1
      params.ti = std::make_shared<torrent_info>(*params.ti);
430
431
1
#if TORRENT_ABI_VERSION == 1
432
1
    handle_backwards_compatible_resume_data(params);
433
1
#endif
434
1
    error_code ec;
435
1
    torrent_handle r = sync_call_ret<torrent_handle>(&session_impl::add_torrent, std::move(params), std::ref(ec));
436
1
    if (ec) aux::throw_ex<system_error>(ec);
437
1
    return r;
438
1
  }
439
440
  torrent_handle session_handle::add_torrent(add_torrent_params const& params)
441
0
  {
442
0
    return add_torrent(add_torrent_params(params));
443
0
  }
444
#endif
445
446
  torrent_handle session_handle::add_torrent(add_torrent_params&& params, error_code& ec)
447
0
  {
448
0
    if (params.save_path.empty())
449
0
    {
450
0
      ec = error_code(errors::invalid_save_path);
451
0
      return {};
452
0
    }
453
454
0
#if TORRENT_ABI_VERSION < 3
455
0
    if (!params.info_hashes.has_v1() && !params.info_hashes.has_v2() && !params.ti)
456
0
      params.info_hashes.v1 = params.info_hash;
457
0
#endif
458
459
    // the internal torrent object keeps and mutates state in the
460
    // torrent_info object. We can't let that leak back to the client
461
0
    if (params.ti)
462
0
      params.ti = std::make_shared<torrent_info>(*params.ti);
463
464
0
    ec.clear();
465
0
#if TORRENT_ABI_VERSION == 1
466
0
    handle_backwards_compatible_resume_data(params);
467
0
#endif
468
0
    return sync_call_ret<torrent_handle>(&session_impl::add_torrent, std::move(params), std::ref(ec));
469
0
  }
470
471
  torrent_handle session_handle::add_torrent(add_torrent_params const& params, error_code& ec)
472
0
  {
473
0
    return add_torrent(add_torrent_params(params), ec);
474
0
  }
475
476
  void session_handle::async_add_torrent(add_torrent_params const& params)
477
1.77k
  {
478
1.77k
    async_add_torrent(add_torrent_params(params));
479
1.77k
  }
480
481
  void session_handle::async_add_torrent(add_torrent_params&& params)
482
1.77k
  {
483
1.77k
#ifndef BOOST_NO_EXCEPTIONS
484
1.77k
    if (params.save_path.empty())
485
0
      aux::throw_ex<system_error>(error_code(errors::invalid_save_path));
486
#else
487
    TORRENT_ASSERT_PRECOND(!params.save_path.empty());
488
#endif
489
490
1.77k
#if TORRENT_ABI_VERSION < 3
491
1.77k
    if (!params.info_hashes.has_v1() && !params.info_hashes.has_v2() && !params.ti)
492
0
      params.info_hashes.v1 = params.info_hash;
493
1.77k
#endif
494
495
    // the internal torrent object keeps and mutates state in the
496
    // torrent_info object. We can't let that leak back to the client
497
1.77k
    if (params.ti)
498
1.77k
      params.ti = std::make_shared<torrent_info>(*params.ti);
499
500
    // we cannot capture a unique_ptr into a lambda in c++11, so we use a raw
501
    // pointer for now. async_call uses a lambda expression to post the call
502
    // to the main thread
503
    // TODO: in C++14, use unique_ptr and move it into the lambda
504
1.77k
    auto* p = new add_torrent_params(std::move(params));
505
1.77k
    auto guard = aux::scope_end([p]{ delete p; });
506
1.77k
    p->save_path = complete(p->save_path);
507
508
1.77k
#if TORRENT_ABI_VERSION == 1
509
1.77k
    handle_backwards_compatible_resume_data(*p);
510
1.77k
#endif
511
512
1.77k
    async_call(&session_impl::async_add_torrent, p);
513
1.77k
    guard.disarm();
514
1.77k
  }
515
516
#ifndef BOOST_NO_EXCEPTIONS
517
#if TORRENT_ABI_VERSION == 1
518
  // if the torrent already exists, this will throw duplicate_torrent
519
  torrent_handle session_handle::add_torrent(
520
    torrent_info const& ti
521
    , std::string const& save_path
522
    , entry const& resume_data
523
    , storage_mode_t storage_mode
524
    , bool const add_paused)
525
0
  {
526
0
    add_torrent_params p;
527
0
    p.ti = std::make_shared<torrent_info>(ti);
528
0
    p.save_path = save_path;
529
0
    if (resume_data.type() != entry::undefined_t)
530
0
    {
531
0
      bencode(std::back_inserter(p.resume_data), resume_data);
532
0
    }
533
0
    p.storage_mode = storage_mode;
534
0
    if (add_paused) p.flags |= add_torrent_params::flag_paused;
535
0
    else p.flags &= ~add_torrent_params::flag_paused;
536
0
    return add_torrent(p);
537
0
  }
538
539
  torrent_handle session_handle::add_torrent(
540
    char const* tracker_url
541
    , sha1_hash const& info_hash
542
    , char const* name
543
    , std::string const& save_path
544
    , entry const& resume_data
545
    , storage_mode_t storage_mode
546
    , bool const add_paused
547
    , client_data_t userdata)
548
0
  {
549
0
#ifndef BOOST_NO_EXCEPTIONS
550
0
    if (save_path.empty())
551
0
      aux::throw_ex<system_error>(error_code(errors::invalid_save_path));
552
#else
553
    TORRENT_ASSERT_PRECOND(!save_path.empty());
554
#endif
555
556
0
    add_torrent_params p;
557
0
    p.trackers.push_back(tracker_url);
558
0
    p.info_hashes.v1 = info_hash;
559
0
    p.save_path = save_path;
560
0
    p.storage_mode = storage_mode;
561
562
0
    if (add_paused) p.flags |= add_torrent_params::flag_paused;
563
0
    else p.flags &= ~add_torrent_params::flag_paused;
564
565
0
    p.userdata = userdata;
566
0
    p.name = name;
567
0
    if (resume_data.type() != entry::undefined_t)
568
0
    {
569
0
      bencode(std::back_inserter(p.resume_data), resume_data);
570
0
    }
571
0
    return add_torrent(p);
572
0
  }
573
#endif // TORRENT_ABI_VERSION
574
#endif // BOOST_NO_EXCEPTIONS
575
576
  void session_handle::pause()
577
0
  {
578
0
    async_call(&session_impl::pause);
579
0
  }
580
581
  void session_handle::resume()
582
0
  {
583
0
    async_call(&session_impl::resume);
584
0
  }
585
586
  bool session_handle::is_paused() const
587
0
  {
588
0
    return sync_call_ret<bool>(&session_impl::is_paused);
589
0
  }
590
591
#if TORRENT_ABI_VERSION == 1
592
  void session_handle::set_load_function(user_load_function_t fun)
593
0
  {
594
0
    async_call(&session_impl::set_load_function, fun);
595
0
  }
596
597
  session_status session_handle::status() const
598
0
  {
599
0
    return sync_call_ret<session_status>(&session_impl::status);
600
0
  }
601
602
  void session_handle::start_dht()
603
0
  {
604
0
    settings_pack p;
605
0
    p.set_bool(settings_pack::enable_dht, true);
606
0
    apply_settings(std::move(p));
607
0
  }
608
609
  void session_handle::stop_dht()
610
0
  {
611
0
    settings_pack p;
612
0
    p.set_bool(settings_pack::enable_dht, false);
613
0
    apply_settings(std::move(p));
614
0
  }
615
#endif // TORRENT_ABI_VERSION
616
617
#if TORRENT_ABI_VERSION <= 2
618
  void session_handle::set_dht_settings(dht::dht_settings const& settings)
619
0
  {
620
0
#ifndef TORRENT_DISABLE_DHT
621
0
    async_call(&session_impl::set_dht_settings, settings);
622
#else
623
    TORRENT_UNUSED(settings);
624
#endif
625
0
  }
626
627
  dht::dht_settings session_handle::get_dht_settings() const
628
0
  {
629
0
#ifndef TORRENT_DISABLE_DHT
630
0
    return sync_call_ret<dht::dht_settings>(&session_impl::get_dht_settings);
631
#else
632
    return dht::dht_settings();
633
#endif
634
0
  }
635
#endif
636
637
  bool session_handle::is_dht_running() const
638
0
  {
639
0
#ifndef TORRENT_DISABLE_DHT
640
0
    return sync_call_ret<bool>(&session_impl::is_dht_running);
641
#else
642
    return false;
643
#endif
644
0
  }
645
646
  void session_handle::set_dht_storage(dht::dht_storage_constructor_type sc)
647
0
  {
648
0
#ifndef TORRENT_DISABLE_DHT
649
0
    async_call(&session_impl::set_dht_storage, sc);
650
#else
651
    TORRENT_UNUSED(sc);
652
#endif
653
0
  }
654
655
  void session_handle::add_dht_node(std::pair<std::string, int> const& node)
656
0
  {
657
0
#ifndef TORRENT_DISABLE_DHT
658
0
    async_call(&session_impl::add_dht_node_name, node);
659
#else
660
    TORRENT_UNUSED(node);
661
#endif
662
0
  }
663
664
#if TORRENT_ABI_VERSION == 1
665
  void session_handle::add_dht_router(std::pair<std::string, int> const& node)
666
0
  {
667
0
#ifndef TORRENT_DISABLE_DHT
668
0
    async_call(&session_impl::add_dht_router, node);
669
#else
670
    TORRENT_UNUSED(node);
671
#endif
672
0
  }
673
#endif // TORRENT_ABI_VERSION
674
675
  void session_handle::dht_get_item(sha1_hash const& target)
676
0
  {
677
0
#ifndef TORRENT_DISABLE_DHT
678
0
    async_call(&session_impl::dht_get_immutable_item, target);
679
#else
680
    TORRENT_UNUSED(target);
681
#endif
682
0
  }
683
684
  void session_handle::dht_get_item(std::array<char, 32> key
685
    , std::string salt)
686
0
  {
687
0
#ifndef TORRENT_DISABLE_DHT
688
0
    async_call(&session_impl::dht_get_mutable_item, key, salt);
689
#else
690
    TORRENT_UNUSED(key);
691
    TORRENT_UNUSED(salt);
692
#endif
693
0
  }
694
695
  // TODO: 3 expose the sequence_number, public_key, secret_key and signature
696
  // types to the client
697
  sha1_hash session_handle::dht_put_item(entry data)
698
0
  {
699
0
    std::vector<char> buf;
700
0
    bencode(std::back_inserter(buf), data);
701
0
    sha1_hash const ret = hasher(buf).final();
702
703
0
#ifndef TORRENT_DISABLE_DHT
704
0
    async_call(&session_impl::dht_put_immutable_item, data, ret);
705
0
#endif
706
0
    return ret;
707
0
  }
708
709
  void session_handle::dht_put_item(std::array<char, 32> key
710
    , std::function<void(entry&, std::array<char,64>&
711
      , std::int64_t&, std::string const&)> cb
712
    , std::string salt)
713
0
  {
714
0
#ifndef TORRENT_DISABLE_DHT
715
0
    async_call(&session_impl::dht_put_mutable_item, key, cb, salt);
716
#else
717
    TORRENT_UNUSED(key);
718
    TORRENT_UNUSED(cb);
719
    TORRENT_UNUSED(salt);
720
#endif
721
0
  }
722
723
  void session_handle::dht_get_peers(sha1_hash const& info_hash)
724
0
  {
725
0
#ifndef TORRENT_DISABLE_DHT
726
0
    async_call(&session_impl::dht_get_peers, info_hash);
727
#else
728
    TORRENT_UNUSED(info_hash);
729
#endif
730
0
  }
731
732
  void session_handle::dht_announce(sha1_hash const& info_hash, int port
733
    , dht::announce_flags_t const flags)
734
0
  {
735
0
#ifndef TORRENT_DISABLE_DHT
736
0
    async_call(&session_impl::dht_announce, info_hash, port, flags);
737
#else
738
    TORRENT_UNUSED(info_hash);
739
    TORRENT_UNUSED(port);
740
    TORRENT_UNUSED(flags);
741
#endif
742
0
  }
743
744
  void session_handle::dht_live_nodes(sha1_hash const& nid)
745
0
  {
746
0
#ifndef TORRENT_DISABLE_DHT
747
0
    async_call(&session_impl::dht_live_nodes, nid);
748
#else
749
    TORRENT_UNUSED(nid);
750
#endif
751
0
  }
752
753
  void session_handle::dht_sample_infohashes(udp::endpoint const& ep, sha1_hash const& target)
754
0
  {
755
0
#ifndef TORRENT_DISABLE_DHT
756
0
    async_call(&session_impl::dht_sample_infohashes, ep, target);
757
#else
758
    TORRENT_UNUSED(ep);
759
    TORRENT_UNUSED(target);
760
#endif
761
0
  }
762
763
  void session_handle::dht_direct_request(udp::endpoint const& ep, entry const& e
764
    , client_data_t userdata)
765
0
  {
766
0
#ifndef TORRENT_DISABLE_DHT
767
0
    entry copy = e;
768
0
    async_call(&session_impl::dht_direct_request, ep, copy, userdata);
769
#else
770
    TORRENT_UNUSED(ep);
771
    TORRENT_UNUSED(e);
772
    TORRENT_UNUSED(userdata);
773
#endif
774
0
  }
775
776
#if TORRENT_ABI_VERSION == 1
777
  entry session_handle::dht_state() const
778
0
  {
779
0
#ifndef TORRENT_DISABLE_DHT
780
0
    return sync_call_ret<entry>(&session_impl::dht_state);
781
#else
782
    return entry();
783
#endif
784
0
  }
785
786
  void session_handle::start_dht(entry const& startup_state)
787
0
  {
788
0
#ifndef TORRENT_DISABLE_DHT
789
0
    async_call(&session_impl::start_dht_deprecated, startup_state);
790
#else
791
    TORRENT_UNUSED(startup_state);
792
#endif
793
0
  }
794
#endif // TORRENT_ABI_VERSION
795
796
  void session_handle::add_extension(std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, client_data_t)> ext)
797
0
  {
798
0
#ifndef TORRENT_DISABLE_EXTENSIONS
799
0
    async_call(&session_impl::add_extension, ext);
800
#else
801
    TORRENT_UNUSED(ext);
802
#endif
803
0
  }
804
805
  void session_handle::add_extension(std::shared_ptr<plugin> ext)
806
0
  {
807
0
#ifndef TORRENT_DISABLE_EXTENSIONS
808
0
    async_call(&session_impl::add_ses_extension, ext);
809
#else
810
    TORRENT_UNUSED(ext);
811
#endif
812
0
  }
813
814
#if TORRENT_ABI_VERSION == 1
815
  void session_handle::load_state(entry const& ses_state
816
    , save_state_flags_t const flags)
817
0
  {
818
0
    if (ses_state.type() == entry::undefined_t) return;
819
0
    std::vector<char> buf;
820
0
    bencode(std::back_inserter(buf), ses_state);
821
0
    bdecode_node e;
822
0
    error_code ec;
823
0
#if TORRENT_USE_ASSERTS || !defined BOOST_NO_EXCEPTIONS
824
0
    int ret =
825
0
#endif
826
0
    bdecode(&buf[0], &buf[0] + buf.size(), e, ec);
827
828
0
    TORRENT_ASSERT(ret == 0);
829
0
#ifndef BOOST_NO_EXCEPTIONS
830
0
    if (ret != 0) aux::throw_ex<system_error>(ec);
831
0
#endif
832
0
    sync_call(&session_impl::load_state, &e, flags);
833
0
  }
834
835
  entry session_handle::state() const
836
0
  {
837
0
    entry ret;
838
0
    auto retp = &ret;
839
0
    sync_call(&session_impl::save_state, retp, save_state_flags_t::all());
840
0
    return ret;
841
0
  }
842
#endif // TORRENT_ABI_VERSION
843
844
  void session_handle::set_ip_filter(ip_filter f)
845
0
  {
846
0
    std::shared_ptr<ip_filter> copy = std::make_shared<ip_filter>(std::move(f));
847
0
    async_call(&session_impl::set_ip_filter, std::move(copy));
848
0
  }
849
850
  ip_filter session_handle::get_ip_filter() const
851
0
  {
852
0
    return sync_call_ret<ip_filter>(&session_impl::get_ip_filter);
853
0
  }
854
855
  void session_handle::set_port_filter(port_filter const& f)
856
0
  {
857
0
    async_call(&session_impl::set_port_filter, f);
858
0
  }
859
860
#if TORRENT_ABI_VERSION == 1
861
  void session_handle::set_peer_id(peer_id const& id)
862
0
  {
863
0
    settings_pack p;
864
0
    p.set_str(settings_pack::peer_fingerprint, id.to_string());
865
0
    apply_settings(std::move(p));
866
0
  }
867
868
  void session_handle::set_key(std::uint32_t)
869
0
  {
870
    // this is just a dummy function now, as we generate the key automatically
871
    // per listen interface
872
0
  }
873
874
  peer_id session_handle::id() const
875
0
  {
876
0
    return sync_call_ret<peer_id>(&session_impl::deprecated_get_peer_id);
877
0
  }
878
#endif
879
880
  unsigned short session_handle::listen_port() const
881
0
  {
882
0
    return sync_call_ret<unsigned short, unsigned short(session_impl::*)() const>
883
0
      (&session_impl::listen_port);
884
0
  }
885
886
  unsigned short session_handle::ssl_listen_port() const
887
0
  {
888
0
    return sync_call_ret<unsigned short, unsigned short(session_impl::*)() const>
889
0
      (&session_impl::ssl_listen_port);
890
0
  }
891
892
  bool session_handle::is_listening() const
893
0
  {
894
0
    return sync_call_ret<bool>(&session_impl::is_listening);
895
0
  }
896
897
  void session_handle::set_peer_class_filter(ip_filter const& f)
898
0
  {
899
0
    async_call(&session_impl::set_peer_class_filter, f);
900
0
  }
901
902
  ip_filter session_handle::get_peer_class_filter() const
903
0
  {
904
0
    return sync_call_ret<ip_filter>(&session_impl::get_peer_class_filter);
905
0
  }
906
907
  void session_handle::set_peer_class_type_filter(peer_class_type_filter const& f)
908
0
  {
909
0
    async_call(&session_impl::set_peer_class_type_filter, f);
910
0
  }
911
912
  peer_class_type_filter session_handle::get_peer_class_type_filter() const
913
0
  {
914
0
    return sync_call_ret<peer_class_type_filter>(&session_impl::get_peer_class_type_filter);
915
0
  }
916
917
  peer_class_t session_handle::create_peer_class(char const* name)
918
0
  {
919
0
    return sync_call_ret<peer_class_t>(&session_impl::create_peer_class, name);
920
0
  }
921
922
  void session_handle::delete_peer_class(peer_class_t cid)
923
0
  {
924
0
    async_call(&session_impl::delete_peer_class, cid);
925
0
  }
926
927
  peer_class_info session_handle::get_peer_class(peer_class_t cid) const
928
0
  {
929
0
    return sync_call_ret<peer_class_info>(&session_impl::get_peer_class, cid);
930
0
  }
931
932
  void session_handle::set_peer_class(peer_class_t cid, peer_class_info const& pci)
933
0
  {
934
0
    async_call(&session_impl::set_peer_class, cid, pci);
935
0
  }
936
937
#if TORRENT_ABI_VERSION == 1
938
  void session_handle::use_interfaces(char const* interfaces)
939
0
  {
940
0
    settings_pack p;
941
0
    p.set_str(settings_pack::outgoing_interfaces, interfaces);
942
0
    apply_settings(std::move(p));
943
0
  }
944
945
  void session_handle::listen_on(
946
    std::pair<int, int> const& port_range
947
    , error_code& ec
948
    , const char* net_interface, int flags)
949
0
  {
950
0
    settings_pack p;
951
0
    std::string interfaces_str;
952
0
    if (net_interface == nullptr || strlen(net_interface) == 0)
953
0
      net_interface = "0.0.0.0";
954
955
0
    interfaces_str = print_endpoint(tcp::endpoint(make_address(net_interface, ec), std::uint16_t(port_range.first)));
956
0
    if (ec) return;
957
958
0
    p.set_str(settings_pack::listen_interfaces, interfaces_str);
959
0
    p.set_int(settings_pack::max_retry_port_bind, port_range.second - port_range.first);
960
0
    p.set_bool(settings_pack::listen_system_port_fallback, (flags & session::listen_no_system_port) == 0);
961
0
    apply_settings(std::move(p));
962
0
  }
963
#endif
964
965
  void session_handle::remove_torrent(const torrent_handle& h, remove_flags_t const options)
966
0
  {
967
0
    if (!h.is_valid())
968
#ifdef BOOST_NO_EXCEPTIONS
969
      return;
970
#else
971
0
      throw_invalid_handle();
972
0
#endif
973
0
    async_call(&session_impl::remove_torrent, h, options);
974
0
  }
975
976
#if TORRENT_ABI_VERSION == 1
977
  void session_handle::set_pe_settings(pe_settings const& r)
978
0
  {
979
0
    settings_pack p;
980
0
    p.set_bool(settings_pack::prefer_rc4, r.prefer_rc4);
981
0
    p.set_int(settings_pack::out_enc_policy, r.out_enc_policy);
982
0
    p.set_int(settings_pack::in_enc_policy, r.in_enc_policy);
983
0
    p.set_int(settings_pack::allowed_enc_level, r.allowed_enc_level);
984
985
0
    apply_settings(std::move(p));
986
0
  }
987
988
  pe_settings session_handle::get_pe_settings() const
989
0
  {
990
0
    settings_pack sett = get_settings();
991
992
0
    pe_settings r;
993
0
    r.prefer_rc4 = sett.get_bool(settings_pack::prefer_rc4);
994
0
    r.out_enc_policy = std::uint8_t(sett.get_int(settings_pack::out_enc_policy));
995
0
    r.in_enc_policy = std::uint8_t(sett.get_int(settings_pack::in_enc_policy));
996
0
    r.allowed_enc_level = std::uint8_t(sett.get_int(settings_pack::allowed_enc_level));
997
0
    return r;
998
0
  }
999
#endif
1000
1001
  void session_handle::apply_settings(settings_pack const& s)
1002
0
  {
1003
0
    TORRENT_ASSERT_PRECOND(!s.has_val(settings_pack::out_enc_policy)
1004
0
      || s.get_int(settings_pack::out_enc_policy)
1005
0
        <= settings_pack::pe_disabled);
1006
0
    TORRENT_ASSERT_PRECOND(!s.has_val(settings_pack::in_enc_policy)
1007
0
      || s.get_int(settings_pack::in_enc_policy)
1008
0
        <= settings_pack::pe_disabled);
1009
0
    TORRENT_ASSERT_PRECOND(!s.has_val(settings_pack::allowed_enc_level)
1010
0
      || s.get_int(settings_pack::allowed_enc_level)
1011
0
        <= settings_pack::pe_both);
1012
1013
0
    auto copy = std::make_shared<settings_pack>(s);
1014
0
    async_call(&session_impl::apply_settings_pack, copy);
1015
0
  }
1016
1017
  void session_handle::apply_settings(settings_pack&& s)
1018
0
  {
1019
0
    TORRENT_ASSERT_PRECOND(!s.has_val(settings_pack::out_enc_policy)
1020
0
      || s.get_int(settings_pack::out_enc_policy)
1021
0
        <= settings_pack::pe_disabled);
1022
0
    TORRENT_ASSERT_PRECOND(!s.has_val(settings_pack::in_enc_policy)
1023
0
      || s.get_int(settings_pack::in_enc_policy)
1024
0
        <= settings_pack::pe_disabled);
1025
0
    TORRENT_ASSERT_PRECOND(!s.has_val(settings_pack::allowed_enc_level)
1026
0
      || s.get_int(settings_pack::allowed_enc_level)
1027
0
        <= settings_pack::pe_both);
1028
1029
0
    auto copy = std::make_shared<settings_pack>(std::move(s));
1030
0
    async_call(&session_impl::apply_settings_pack, copy);
1031
0
  }
1032
1033
  settings_pack session_handle::get_settings() const
1034
0
  {
1035
0
    return sync_call_ret<settings_pack>(&session_impl::get_settings);
1036
0
  }
1037
1038
#if TORRENT_ABI_VERSION == 1
1039
  void session_handle::set_i2p_proxy(proxy_settings const& s)
1040
0
  {
1041
0
    settings_pack pack;
1042
0
    pack.set_str(settings_pack::i2p_hostname, s.hostname);
1043
0
    pack.set_int(settings_pack::i2p_port, s.port);
1044
1045
0
    apply_settings(pack);
1046
0
  }
1047
1048
  proxy_settings session_handle::i2p_proxy() const
1049
0
  {
1050
0
    proxy_settings ret;
1051
0
    settings_pack sett = get_settings();
1052
0
    ret.hostname = sett.get_str(settings_pack::i2p_hostname);
1053
0
    ret.port = std::uint16_t(sett.get_int(settings_pack::i2p_port));
1054
0
    return ret;
1055
0
  }
1056
1057
  void session_handle::set_proxy(proxy_settings const& s)
1058
0
  {
1059
0
    settings_pack p;
1060
0
    p.set_str(settings_pack::proxy_hostname, s.hostname);
1061
0
    p.set_str(settings_pack::proxy_username, s.username);
1062
0
    p.set_str(settings_pack::proxy_password, s.password);
1063
0
    p.set_int(settings_pack::proxy_type, s.type);
1064
0
    p.set_int(settings_pack::proxy_port, s.port);
1065
0
    p.set_bool(settings_pack::proxy_hostnames,s.proxy_hostnames);
1066
0
    p.set_bool(settings_pack::proxy_peer_connections, s.proxy_peer_connections);
1067
1068
0
    apply_settings(std::move(p));
1069
0
  }
1070
1071
  proxy_settings session_handle::proxy() const
1072
0
  {
1073
0
    settings_pack sett = get_settings();
1074
0
    return proxy_settings(sett);
1075
0
  }
1076
1077
  int session_handle::num_uploads() const
1078
0
  {
1079
0
    return sync_call_ret<int>(&session_impl::num_uploads);
1080
0
  }
1081
1082
  int session_handle::num_connections() const
1083
0
  {
1084
0
    return sync_call_ret<int>(&session_impl::num_connections);
1085
0
  }
1086
1087
  void session_handle::set_peer_proxy(proxy_settings const& s)
1088
0
  {
1089
0
    set_proxy(s);
1090
0
  }
1091
1092
  void session_handle::set_web_seed_proxy(proxy_settings const&)
1093
0
  {
1094
    // NO-OP
1095
0
  }
1096
1097
  void session_handle::set_tracker_proxy(proxy_settings const& s)
1098
0
  {
1099
    // if the tracker proxy is enabled, set the "proxy_tracker_connections"
1100
    // setting
1101
0
    settings_pack pack;
1102
0
    pack.set_bool(settings_pack::proxy_tracker_connections
1103
0
      , s.type != settings_pack::none);
1104
0
    apply_settings(pack);
1105
0
  }
1106
1107
  proxy_settings session_handle::peer_proxy() const
1108
0
  {
1109
0
    return proxy();
1110
0
  }
1111
1112
  proxy_settings session_handle::web_seed_proxy() const
1113
0
  {
1114
0
    return proxy();
1115
0
  }
1116
1117
  proxy_settings session_handle::tracker_proxy() const
1118
0
  {
1119
0
    settings_pack const sett = get_settings();
1120
0
    return sett.get_bool(settings_pack::proxy_tracker_connections)
1121
0
      ? proxy_settings(sett) : proxy_settings();
1122
0
  }
1123
1124
  void session_handle::set_dht_proxy(proxy_settings const&)
1125
0
  {
1126
    // NO-OP
1127
0
  }
1128
1129
  proxy_settings session_handle::dht_proxy() const
1130
0
  {
1131
0
    return proxy();
1132
0
  }
1133
1134
  int session_handle::upload_rate_limit() const
1135
0
  {
1136
0
    return sync_call_ret<int>(&session_impl::upload_rate_limit_depr);
1137
0
  }
1138
1139
  int session_handle::download_rate_limit() const
1140
0
  {
1141
0
    return sync_call_ret<int>(&session_impl::download_rate_limit_depr);
1142
0
  }
1143
1144
  int session_handle::local_upload_rate_limit() const
1145
0
  {
1146
0
    return sync_call_ret<int>(&session_impl::local_upload_rate_limit);
1147
0
  }
1148
1149
  int session_handle::local_download_rate_limit() const
1150
0
  {
1151
0
    return sync_call_ret<int>(&session_impl::local_download_rate_limit);
1152
0
  }
1153
1154
0
  int session_handle::max_half_open_connections() const { return 8; }
1155
1156
  void session_handle::set_local_upload_rate_limit(int bytes_per_second)
1157
0
  {
1158
0
    async_call(&session_impl::set_local_upload_rate_limit, bytes_per_second);
1159
0
  }
1160
1161
  void session_handle::set_local_download_rate_limit(int bytes_per_second)
1162
0
  {
1163
0
    async_call(&session_impl::set_local_download_rate_limit, bytes_per_second);
1164
0
  }
1165
1166
  void session_handle::set_upload_rate_limit(int bytes_per_second)
1167
0
  {
1168
0
    async_call(&session_impl::set_upload_rate_limit_depr, bytes_per_second);
1169
0
  }
1170
1171
  void session_handle::set_download_rate_limit(int bytes_per_second)
1172
0
  {
1173
0
    async_call(&session_impl::set_download_rate_limit_depr, bytes_per_second);
1174
0
  }
1175
1176
  void session_handle::set_max_connections(int limit)
1177
0
  {
1178
0
    async_call(&session_impl::set_max_connections, limit);
1179
0
  }
1180
1181
  void session_handle::set_max_uploads(int limit)
1182
0
  {
1183
0
    async_call(&session_impl::set_max_uploads, limit);
1184
0
  }
1185
1186
0
  void session_handle::set_max_half_open_connections(int) {}
1187
1188
  int session_handle::max_uploads() const
1189
0
  {
1190
0
    return sync_call_ret<int>(&session_impl::max_uploads);
1191
0
  }
1192
1193
  int session_handle::max_connections() const
1194
0
  {
1195
0
    return sync_call_ret<int>(&session_impl::max_connections);
1196
0
  }
1197
1198
#endif // TORRENT_ABI_VERSION
1199
1200
  // the alerts are const, they may not be deleted by the client
1201
  void session_handle::pop_alerts(std::vector<alert*>* alerts)
1202
3
  {
1203
3
    std::shared_ptr<session_impl> s = m_impl.lock();
1204
3
    if (!s) aux::throw_ex<system_error>(errors::invalid_session_handle);
1205
3
    s->pop_alerts(alerts);
1206
3
  }
1207
1208
  alert* session_handle::wait_for_alert(time_duration max_wait)
1209
3
  {
1210
3
    std::shared_ptr<session_impl> s = m_impl.lock();
1211
3
    if (!s) aux::throw_ex<system_error>(errors::invalid_session_handle);
1212
3
    return s->wait_for_alert(max_wait);
1213
3
  }
1214
1215
  void session_handle::set_alert_notify(std::function<void()> const& fun)
1216
0
  {
1217
0
    std::shared_ptr<session_impl> s = m_impl.lock();
1218
0
    if (!s) aux::throw_ex<system_error>(errors::invalid_session_handle);
1219
0
    s->alerts().set_notify_function(fun);
1220
0
  }
1221
1222
#if TORRENT_ABI_VERSION == 1
1223
  size_t session_handle::set_alert_queue_size_limit(size_t queue_size_limit_)
1224
0
  {
1225
0
    return sync_call_ret<size_t>(&session_impl::set_alert_queue_size_limit, queue_size_limit_);
1226
0
  }
1227
1228
  void session_handle::set_alert_mask(std::uint32_t m)
1229
0
  {
1230
0
    settings_pack p;
1231
0
    p.set_int(settings_pack::alert_mask, int(m));
1232
0
    apply_settings(std::move(p));
1233
0
  }
1234
1235
  std::uint32_t session_handle::get_alert_mask() const
1236
0
  {
1237
0
    return std::uint32_t(get_settings().get_int(settings_pack::alert_mask));
1238
0
  }
1239
1240
  void session_handle::start_lsd()
1241
0
  {
1242
0
    settings_pack p;
1243
0
    p.set_bool(settings_pack::enable_lsd, true);
1244
0
    apply_settings(std::move(p));
1245
0
  }
1246
1247
  void session_handle::stop_lsd()
1248
0
  {
1249
0
    settings_pack p;
1250
0
    p.set_bool(settings_pack::enable_lsd, false);
1251
0
    apply_settings(std::move(p));
1252
0
  }
1253
1254
  void session_handle::start_upnp()
1255
0
  {
1256
0
    settings_pack p;
1257
0
    p.set_bool(settings_pack::enable_upnp, true);
1258
0
    apply_settings(std::move(p));
1259
0
  }
1260
1261
  void session_handle::stop_upnp()
1262
0
  {
1263
0
    settings_pack p;
1264
0
    p.set_bool(settings_pack::enable_upnp, false);
1265
0
    apply_settings(std::move(p));
1266
0
  }
1267
1268
  void session_handle::start_natpmp()
1269
0
  {
1270
0
    settings_pack p;
1271
0
    p.set_bool(settings_pack::enable_natpmp, true);
1272
0
    apply_settings(std::move(p));
1273
0
  }
1274
1275
  void session_handle::stop_natpmp()
1276
0
  {
1277
0
    settings_pack p;
1278
0
    p.set_bool(settings_pack::enable_natpmp, false);
1279
0
    apply_settings(std::move(p));
1280
0
  }
1281
#endif // TORRENT_ABI_VERSION
1282
1283
  std::vector<port_mapping_t> session_handle::add_port_mapping(portmap_protocol const t
1284
    , int external_port, int local_port)
1285
0
  {
1286
0
    return sync_call_ret<std::vector<port_mapping_t>>(&session_impl::add_port_mapping, t, external_port, local_port);
1287
0
  }
1288
1289
  void session_handle::delete_port_mapping(port_mapping_t handle)
1290
0
  {
1291
0
    async_call(&session_impl::delete_port_mapping, handle);
1292
0
  }
1293
1294
  void session_handle::reopen_network_sockets(reopen_network_flags_t const options)
1295
0
  {
1296
0
    async_call(&session_impl::reopen_network_sockets, options);
1297
0
  }
1298
1299
} // namespace libtorrent