diff --git a/src/connectionmanager.cpp b/src/connectionmanager.cpp index 45dc64c..266fa08 100644 --- a/src/connectionmanager.cpp +++ b/src/connectionmanager.cpp @@ -428,9 +428,9 @@ class ConnectionManager::Impl : public std::enable_shared_from_this config_) - : config_ {std::move(createConfig(config_))} + : treatedMessages_ {config_->cachePath / "treatedMessages"} + , config_ {createConfig(config_)} , rand_ {config_->rng ? *config_->rng : dht::crypto::getSeededRandomEngine()} - , treatedMessages_ {config_->cachePath / "treatedMessages"} { if(!config_->ioContext) { config_->ioContext = std::make_shared(); @@ -1572,7 +1572,7 @@ ConnectionManager::Impl::addNewMultiplexedSocket(const std::weak_ptr std::unique_lock lkc(info->mutex_); auto ids = std::move(info->pendingCbs_); auto [ops, retry] = deviceInfo->resetPendingOperations(ids); - auto erased = deviceInfo->info.erase(vid); + deviceInfo->info.erase(vid); if (!retry && deviceInfo->empty()) { if (auto sthis = w.lock()) sthis->infos_.removeDeviceInfo(deviceInfo->deviceId); diff --git a/src/multiplexed_socket.cpp b/src/multiplexed_socket.cpp index 910e31e..6d1e002 100644 --- a/src/multiplexed_socket.cpp +++ b/src/multiplexed_socket.cpp @@ -63,11 +63,11 @@ class MultiplexedSocket::Impl std::unique_ptr ep, std::shared_ptr logger) : parent_(parent) + , logger_(std::move(logger)) , ctx_(std::move(ctx)) , deviceId(deviceId) , endpoint(std::move(ep)) , nextChannel_(endpoint->isInitiator() ? 0x0001u : 0x8000u) - , logger_(std::move(logger)) , eventLoopThread_ {[this] { try { eventLoop(); diff --git a/src/upnp/upnp_context.cpp b/src/upnp/upnp_context.cpp index 8bb2fec..38a5a85 100644 --- a/src/upnp/upnp_context.cpp +++ b/src/upnp/upnp_context.cpp @@ -47,10 +47,10 @@ constexpr static uint16_t UPNP_UDP_PORT_MAX {UPNP_UDP_PORT_MIN + 5000}; UPnPContext::UPnPContext(const std::shared_ptr& ioContext, const std::shared_ptr& logger) : ctx(createIoContext(ioContext, logger)) , logger_(logger) + , connectivityChangedTimer_(*ctx) , mappingRenewalTimer_(*ctx) , renewalSchedulingTimer_(*ctx) , syncTimer_(*ctx) - , connectivityChangedTimer_(*ctx) , igdDiscoveryTimer_(*ctx) { diff --git a/tools/common.cpp b/tools/common.cpp index 06b9208..62562fb 100644 --- a/tools/common.cpp +++ b/tools/common.cpp @@ -103,7 +103,7 @@ connectionManagerConfig(dht::crypto::Identity identity, config->upnpCtrl = controller; } - return std::move(config); + return config; } template void diff --git a/tools/dnc/dnc.cpp b/tools/dnc/dnc.cpp index 7ed1fc4..fccd694 100644 --- a/tools/dnc/dnc.cpp +++ b/tools/dnc/dnc.cpp @@ -64,8 +64,8 @@ Dnc::Dnc(dht::crypto::Identity identity, const std::map> authorized_services, const bool enable_upnp) :logger(verbose ? dht::log::getStdLogger() : nullptr), - ioContext(std::make_shared()), - iceFactory(std::make_shared(logger)) + iceFactory(std::make_shared(logger)), + ioContext(std::make_shared()) { certStore = std::make_shared(cachePath()/"certStore", logger); @@ -157,16 +157,16 @@ Dnc::Dnc(dht::crypto::Identity identity, asio::async_connect( *socket, endpoints, - [this, socket, mtlxSocket](const std::error_code& error, + [socket, mtlxSocket](const std::error_code& error, const asio::ip::tcp::endpoint& ep) { if (!error) { Log("Connected!\n"); - mtlxSocket->setOnRecv([socket, this](const uint8_t* data, size_t size) { + mtlxSocket->setOnRecv([socket](const uint8_t* data, size_t size) { auto data_copy = std::make_shared>(data, data + size); asio::async_write(*socket, asio::buffer(*data_copy), - [data_copy, this](const std::error_code& error, + [data_copy](const std::error_code& error, std::size_t bytesWritten) { if (error) { Log("Write error: {}\n", error.message()); @@ -209,7 +209,7 @@ Dnc::Dnc(dht::crypto::Identity identity, connectionManager->connectDevice( peer_id, name, [&](std::shared_ptr socket, const dht::InfoHash&) { if (socket) { - socket->setOnRecv([this, socket](const uint8_t* data, size_t size) { + socket->setOnRecv([socket](const uint8_t* data, size_t size) { std::cout.write((const char*) data, size); std::cout.flush(); return size; diff --git a/tools/dsh/dsh.cpp b/tools/dsh/dsh.cpp index 5dcfb0b..5b13fc8 100644 --- a/tools/dsh/dsh.cpp +++ b/tools/dsh/dsh.cpp @@ -93,9 +93,9 @@ dhtnet::Dsh::Dsh(dht::crypto::Identity identity, const std::string& turn_realm, bool anonymous) :logger(dht::log::getStdLogger()), - ioContext(std::make_shared()), - iceFactory(std::make_shared(logger)), certStore(std::make_shared(cachePath()/"certstore", logger)), + iceFactory(std::make_shared(logger)), + ioContext(std::make_shared()), trustStore(std::make_shared(*certStore)) { auto ca = identity.second->issuer; @@ -223,7 +223,7 @@ dhtnet::Dsh::Dsh(dht::crypto::Identity identity, connectionManager->connectDevice( peer_id, binary, [&](std::shared_ptr socket, const dht::InfoHash&) { if (socket) { - socket->setOnRecv([this, socket](const uint8_t* data, size_t size) { + socket->setOnRecv([socket](const uint8_t* data, size_t size) { std::cout.write((const char*) data, size); std::cout.flush(); return size;