Skip to content

Commit

Permalink
Merge pull request #7 from twisterarmy/master
Browse files Browse the repository at this point in the history
Master updates
  • Loading branch information
d47081 authored Jul 9, 2022
2 parents 42cb769 + efd1c8c commit bfd7a06
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 81 deletions.
8 changes: 4 additions & 4 deletions libtorrent/include/libtorrent/alert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace libtorrent {
severity_t severity() const TORRENT_DEPRECATED { return warning; }
#endif

virtual std::auto_ptr<alert> clone() const = 0;
virtual std::unique_ptr<alert> clone() const = 0;

private:
ptime m_timestamp;
Expand All @@ -133,7 +133,7 @@ namespace libtorrent {
template<class Handler
, BOOST_PP_ENUM_PARAMS(TORRENT_MAX_ALERT_TYPES, class T)>
void handle_alert_dispatch(
const std::auto_ptr<alert>& alert_, const Handler& handler
const std::unique_ptr<alert>& alert_, const Handler& handler
, const std::type_info& typeid_
, T0*, BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS(TORRENT_MAX_ALERT_TYPES, T, *p))
{
Expand All @@ -147,7 +147,7 @@ namespace libtorrent {

template<class Handler>
void handle_alert_dispatch(
const std::auto_ptr<alert>&
const std::unique_ptr<alert>&
, const Handler&
, const std::type_info&
, BOOST_PP_ENUM_PARAMS(TORRENT_MAX_ALERT_TYPES, void_* BOOST_PP_INTERCEPT))
Expand All @@ -162,7 +162,7 @@ namespace libtorrent {
struct TORRENT_EXPORT handle_alert
{
template<class Handler>
handle_alert(const std::auto_ptr<alert>& alert_
handle_alert(const std::unique_ptr<alert>& alert_
, const Handler& handler)
{
#define ALERT_POINTER_TYPE(z, n, text) (BOOST_PP_CAT(T, n)*)0
Expand Down
8 changes: 4 additions & 4 deletions libtorrent/include/libtorrent/alert_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace libtorrent {
void post_alert(const alert& alert_);
void post_alert_ptr(alert* alert_);
bool pending() const;
std::auto_ptr<alert> get();
std::unique_ptr<alert> get();
void get_all(std::deque<alert*>* alerts);

template <class T>
Expand Down Expand Up @@ -86,21 +86,21 @@ namespace libtorrent {
size_t alert_queue_size_limit() const { return m_queue_size_limit; }
size_t set_alert_queue_size_limit(size_t queue_size_limit_);

void set_dispatch_function(boost::function<void(std::auto_ptr<alert>)> const&);
void set_dispatch_function(std::function<void(std::unique_ptr<alert>&&)> const&);

#ifndef TORRENT_DISABLE_EXTENSIONS
void add_extension(boost::shared_ptr<plugin> ext);
#endif

private:
void post_impl(std::auto_ptr<alert>& alert_, mutex::scoped_lock& l);
void post_impl(std::unique_ptr<alert>&& alert_, mutex::scoped_lock& l);

std::deque<alert*> m_alerts;
mutable mutex m_mutex;
condition_variable m_condition;
boost::uint32_t m_alert_mask;
size_t m_queue_size_limit;
boost::function<void(std::auto_ptr<alert>)> m_dispatch;
std::function<void(std::unique_ptr<alert>&&)> m_dispatch;

#ifndef TORRENT_DISABLE_EXTENSIONS
typedef std::list<boost::shared_ptr<plugin> > ses_extension_list_t;
Expand Down
4 changes: 2 additions & 2 deletions libtorrent/include/libtorrent/alert_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ namespace libtorrent
#define TORRENT_DEFINE_ALERT(name) \
const static int alert_type = __LINE__; \
virtual int type() const { return alert_type; } \
virtual std::auto_ptr<alert> clone() const \
{ return std::auto_ptr<alert>(new name(*this)); } \
virtual std::unique_ptr<alert> clone() const \
{ return std::unique_ptr<alert>(new name(*this)); } \
virtual int category() const { return static_category; } \
virtual char const* what() const { return #name; }

Expand Down
4 changes: 2 additions & 2 deletions libtorrent/include/libtorrent/aux_/session_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,9 @@ namespace libtorrent

void set_alert_mask(boost::uint32_t m);
size_t set_alert_queue_size_limit(size_t queue_size_limit_);
std::auto_ptr<alert> pop_alert();
std::unique_ptr<alert> pop_alert();
void pop_alerts(std::deque<alert*>* alerts);
void set_alert_dispatch(boost::function<void(std::auto_ptr<alert>)> const&);
void set_alert_dispatch(boost::function<void(std::unique_ptr<alert>)> const&);
void post_alert(const alert& alert_);

alert const* wait_for_alert(time_duration max_wait);
Expand Down
4 changes: 2 additions & 2 deletions libtorrent/include/libtorrent/session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ namespace libtorrent
//
// ``save_resume_data_alert`` and ``save_resume_data_failed_alert`` are always posted, regardelss
// of the alert mask.
std::auto_ptr<alert> pop_alert();
std::unique_ptr<alert> pop_alert();
void pop_alerts(std::deque<alert*>* alerts);
alert const* wait_for_alert(time_duration max_wait);

Expand All @@ -821,7 +821,7 @@ namespace libtorrent
// The main intention with this function is to support integration with platform-dependent message
// queues or signalling systems. For instance, on windows, one could post a message to an HNWD or
// on linux, write to a pipe or an eventfd.
void set_alert_dispatch(boost::function<void(std::auto_ptr<alert>)> const& fun);
void set_alert_dispatch(boost::function<void(std::unique_ptr<alert>)> const& fun);

connection_queue& get_connection_queue();

Expand Down
24 changes: 12 additions & 12 deletions libtorrent/src/alert_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace libtorrent
return NULL;
}

void alert_manager::set_dispatch_function(boost::function<void(std::auto_ptr<alert>)> const& fun)
void alert_manager::set_dispatch_function(std::function<void(std::unique_ptr<alert>&&)> const& fun)
{
mutex::scoped_lock lock(m_mutex);

Expand All @@ -85,7 +85,7 @@ namespace libtorrent
while (!alerts.empty())
{
TORRENT_TRY {
m_dispatch(std::auto_ptr<alert>(alerts.front()));
m_dispatch(std::unique_ptr<alert>(alerts.front()));
} TORRENT_CATCH(std::exception&) {}
alerts.pop_front();
}
Expand All @@ -94,13 +94,13 @@ namespace libtorrent
void dispatch_alert(boost::function<void(alert const&)> dispatcher
, alert* alert_)
{
std::auto_ptr<alert> holder(alert_);
std::unique_ptr<alert> holder(alert_);
dispatcher(*alert_);
}

void alert_manager::post_alert_ptr(alert* alert_)
{
std::auto_ptr<alert> a(alert_);
std::unique_ptr<alert> a(alert_);

#ifndef TORRENT_DISABLE_EXTENSIONS
for (ses_extension_list_t::iterator i = m_ses_extensions.begin()
Expand All @@ -113,12 +113,12 @@ namespace libtorrent
#endif

mutex::scoped_lock lock(m_mutex);
post_impl(a, lock);
post_impl(std::move(a), lock);
}

void alert_manager::post_alert(const alert& alert_)
{
std::auto_ptr<alert> a(alert_.clone());
std::unique_ptr<alert> a(alert_.clone());

#ifndef TORRENT_DISABLE_EXTENSIONS
for (ses_extension_list_t::iterator i = m_ses_extensions.begin()
Expand All @@ -131,16 +131,16 @@ namespace libtorrent
#endif

mutex::scoped_lock lock(m_mutex);
post_impl(a, lock);
post_impl(std::move(a), lock);
}

void alert_manager::post_impl(std::auto_ptr<alert>& alert_, mutex::scoped_lock& l)
void alert_manager::post_impl(std::unique_ptr<alert>&& alert_, mutex::scoped_lock& l)
{
if (m_dispatch)
{
TORRENT_ASSERT(m_alerts.empty());
TORRENT_TRY {
m_dispatch(alert_);
m_dispatch(std::move(alert_));
} TORRENT_CATCH(std::exception&) {}
}
else if (m_alerts.size() < m_queue_size_limit || !alert_->discardable())
Expand All @@ -158,16 +158,16 @@ namespace libtorrent
}
#endif

std::auto_ptr<alert> alert_manager::get()
std::unique_ptr<alert> alert_manager::get()
{
mutex::scoped_lock lock(m_mutex);

if (m_alerts.empty())
return std::auto_ptr<alert>(0);
return std::unique_ptr<alert>(nullptr);

alert* result = m_alerts.front();
m_alerts.pop_front();
return std::auto_ptr<alert>(result);
return std::unique_ptr<alert>(result);
}

void alert_manager::get_all(std::deque<alert*>* alerts)
Expand Down
4 changes: 2 additions & 2 deletions libtorrent/src/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1096,12 +1096,12 @@ namespace libtorrent
}
#endif // TORRENT_NO_DEPRECATE

void session::set_alert_dispatch(boost::function<void(std::auto_ptr<alert>)> const& fun)
void session::set_alert_dispatch(boost::function<void(std::unique_ptr<alert>)> const& fun)
{
TORRENT_ASYNC_CALL1(set_alert_dispatch, fun);
}

std::auto_ptr<alert> session::pop_alert()
std::unique_ptr<alert> session::pop_alert()
{
return m_impl->pop_alert();
}
Expand Down
6 changes: 3 additions & 3 deletions libtorrent/src/session_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5037,7 +5037,7 @@ namespace aux {

TORRENT_ASSERT(is_network_thread());

std::auto_ptr<state_update_alert> alert(new state_update_alert());
std::unique_ptr<state_update_alert> alert(new state_update_alert());
alert->status.reserve(m_state_updates.size());

#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
Expand Down Expand Up @@ -6157,12 +6157,12 @@ namespace aux {
}
}

void session_impl::set_alert_dispatch(boost::function<void(std::auto_ptr<alert>)> const& fun)
void session_impl::set_alert_dispatch(boost::function<void(std::unique_ptr<alert>)> const& fun)
{
m_alerts.set_dispatch_function(fun);
}

std::auto_ptr<alert> session_impl::pop_alert()
std::unique_ptr<alert> session_impl::pop_alert()
{
return m_alerts.get();
}
Expand Down
2 changes: 1 addition & 1 deletion libtorrent/src/torrent_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ namespace libtorrent

struct string_less_no_case
{
bool operator()(std::string const& lhs, std::string const& rhs)
bool operator()(std::string const& lhs, std::string const& rhs) const
{
char c1, c2;
char const* s1 = lhs.c_str();
Expand Down
6 changes: 3 additions & 3 deletions libtorrent/test/setup_transfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ void report_failure(char const* err, char const* file, int line)
tests_failure = true;
}

std::auto_ptr<alert> wait_for_alert(session& ses, int type)
std::unique_ptr<alert> wait_for_alert(session& ses, int type)
{
std::auto_ptr<alert> ret;
std::unique_ptr<alert> ret;
while (!ret.get())
{
ses.wait_for_alert(milliseconds(5000));
Expand All @@ -86,7 +86,7 @@ std::auto_ptr<alert> wait_for_alert(session& ses, int type)
{
if (!ret.get() && (*i)->type() == type)
{
ret = std::auto_ptr<alert>(*i);
ret = std::unique_ptr<alert>(*i);
}
else
delete *i;
Expand Down
2 changes: 1 addition & 1 deletion libtorrent/test/setup_transfer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int EXPORT load_file(std::string const& filename, std::vector<char>& v, libtorre

void EXPORT report_failure(char const* err, char const* file, int line);

std::auto_ptr<libtorrent::alert> EXPORT wait_for_alert(libtorrent::session& ses, int type);
std::unique_ptr<libtorrent::alert> EXPORT wait_for_alert(libtorrent::session& ses, int type);

void EXPORT print_ses_rate(float time
, libtorrent::torrent_status const* st1
Expand Down
14 changes: 7 additions & 7 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,14 +954,14 @@ void StartRPCThreads()
{
rpc_ssl_context->set_options(ssl::context::no_sslv2);

filesystem::path pathCertFile(GetArg("-rpcsslcertificatechainfile", "server.cert"));
if (!pathCertFile.is_complete()) pathCertFile = filesystem::path(GetDataDir()) / pathCertFile;
if (filesystem::exists(pathCertFile)) rpc_ssl_context->use_certificate_chain_file(pathCertFile.string());
boost::filesystem::path pathCertFile(GetArg("-rpcsslcertificatechainfile", "server.cert"));
if (!pathCertFile.is_complete()) pathCertFile = boost::filesystem::path(GetDataDir()) / pathCertFile;
if (boost::filesystem::exists(pathCertFile)) rpc_ssl_context->use_certificate_chain_file(pathCertFile.string());
else printf("ThreadRPCServer ERROR: missing server certificate file %s\n", pathCertFile.string().c_str());

filesystem::path pathPKFile(GetArg("-rpcsslprivatekeyfile", "server.pem"));
if (!pathPKFile.is_complete()) pathPKFile = filesystem::path(GetDataDir()) / pathPKFile;
if (filesystem::exists(pathPKFile)) rpc_ssl_context->use_private_key_file(pathPKFile.string(), ssl::context::pem);
boost::filesystem::path pathPKFile(GetArg("-rpcsslprivatekeyfile", "server.pem"));
if (!pathPKFile.is_complete()) pathPKFile = boost::filesystem::path(GetDataDir()) / pathPKFile;
if (boost::filesystem::exists(pathPKFile)) rpc_ssl_context->use_private_key_file(pathPKFile.string(), ssl::context::pem);
else printf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string().c_str());

string strCiphers = GetArg("-rpcsslciphers", "TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH");
Expand Down Expand Up @@ -1182,7 +1182,7 @@ void ServiceConnection(AcceptedConnection *conn)
strURI="/home.html";

if (strURI != "/" && strURI.substr(0, 4) != "/rss" && strURI.find("..") == std::string::npos ) {
filesystem::path pathFile = filesystem::path(GetHTMLDir()) / strURI;
boost::filesystem::path pathFile = boost::filesystem::path(GetHTMLDir()) / strURI;
std::string fname = pathFile.string();
size_t qMarkIdx = fname.find('?');
if( qMarkIdx != string::npos ) {
Expand Down
6 changes: 3 additions & 3 deletions src/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn)
boost::this_thread::interruption_point();

path = pathIn;
filesystem::path pathLogDir = path / "database";
filesystem::create_directory(pathLogDir);
filesystem::path pathErrorFile = path / "db.log";
boost::filesystem::path pathLogDir = path / "database";
boost::filesystem::create_directory(pathLogDir);
boost::filesystem::path pathErrorFile = path / "db.log";
printf("dbenv.open LogDir=%s ErrorFile=%s\n", pathLogDir.string().c_str(), pathErrorFile.string().c_str());

unsigned int nEnvFlags = 0;
Expand Down
24 changes: 12 additions & 12 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,12 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
}

// hardcoded $DATADIR/bootstrap.dat
filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat";
if (filesystem::exists(pathBootstrap)) {
boost::filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat";
if (boost::filesystem::exists(pathBootstrap)) {
FILE *file = fopen(pathBootstrap.string().c_str(), "rb");
if (file) {
CImportingNow imp;
filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
boost::filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
printf("Importing bootstrap.dat...\n");
LoadExternalBlockFile(file);
RenameOver(pathBootstrap, pathBootstrapOld);
Expand Down Expand Up @@ -571,7 +571,7 @@ bool AppInit2(boost::thread_group& threadGroup)
return false;
}

if (filesystem::exists(GetDataDir() / "twisterwallet.dat"))
if (boost::filesystem::exists(GetDataDir() / "twisterwallet.dat"))
{
CDBEnv::VerifyResult r = bitdb.Verify("twisterwallet.dat", CWalletDB::Recover);
if (r == CDBEnv::RECOVER_OK)
Expand Down Expand Up @@ -700,20 +700,20 @@ bool AppInit2(boost::thread_group& threadGroup)
fReindex = GetBoolArg("-reindex", false);

// Upgrading to 0.8; hard-link the old blknnnn.dat files into /blocks/
filesystem::path blocksDir = GetDataDir() / "blocks";
if (!filesystem::exists(blocksDir))
boost::filesystem::path blocksDir = GetDataDir() / "blocks";
if (!boost::filesystem::exists(blocksDir))
{
filesystem::create_directories(blocksDir);
boost::filesystem::create_directories(blocksDir);
bool linked = false;
for (unsigned int i = 1; i < 10000; i++) {
filesystem::path source = GetDataDir() / strprintf("blk%04u.dat", i);
if (!filesystem::exists(source)) break;
filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i-1);
boost::filesystem::path source = GetDataDir() / strprintf("blk%04u.dat", i);
if (!boost::filesystem::exists(source)) break;
boost::filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i-1);
try {
filesystem::create_hard_link(source, dest);
boost::filesystem::create_hard_link(source, dest);
printf("Hardlinked %s -> %s\n", source.string().c_str(), dest.string().c_str());
linked = true;
} catch (filesystem::filesystem_error & e) {
} catch (boost::filesystem::filesystem_error & e) {
// Note: hardlink creation failing is not a disaster, it just means
// blocks will get re-downloaded from peers.
printf("Error hardlinking blk%04u.dat : %s\n", i, e.what());
Expand Down
2 changes: 1 addition & 1 deletion src/key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned ch
if (!BN_bin2bn(msg, msglen, e)) { ret=-1; goto err; }
if (8*msglen > n) BN_rshift(e, e, 8-(n & 7));
zero = BN_CTX_get(ctx);
if (!BN_zero(zero)) { ret=-1; goto err; }
BN_zero(zero);
if (!BN_mod_sub(e, zero, e, order, ctx)) { ret=-1; goto err; }
rr = BN_CTX_get(ctx);
#if (OPENSSL_VERSION_NUMBER < 0x10100000)
Expand Down
Loading

0 comments on commit bfd7a06

Please sign in to comment.