mirror of
https://github.com/resiprocate/resiprocate.git
synced 2026-01-12 00:05:02 +08:00
Merge pull request #448 from Lastique/feature/fix_cxx20_implicit_this_captures
Fix deprecated implicit this captures and dangling pointer captures
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#include <rutil/Logger.hxx>
|
#include <rutil/Logger.hxx>
|
||||||
#include "../ReTurnSubsystem.hxx"
|
#include "../ReTurnSubsystem.hxx"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#define RESIPROCATE_SUBSYSTEM ReTurnSubsystem::RETURN
|
#define RESIPROCATE_SUBSYSTEM ReTurnSubsystem::RETURN
|
||||||
@@ -94,34 +95,33 @@ TurnAsyncSocket::doRequestSharedSecret()
|
|||||||
void
|
void
|
||||||
TurnAsyncSocket::setUsernameAndPassword(const char* username, const char* password, bool shortTermAuth)
|
TurnAsyncSocket::setUsernameAndPassword(const char* username, const char* password, bool shortTermAuth)
|
||||||
{
|
{
|
||||||
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=] { doSetUsernameAndPassword(new Data(username), new Data(password), shortTermAuth); }));
|
Data username_copy{username}, password_copy{password};
|
||||||
|
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=, this]() mutable { doSetUsernameAndPassword(std::move(username_copy), std::move(password_copy), shortTermAuth); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TurnAsyncSocket::doSetUsernameAndPassword(Data* username, Data* password, bool shortTermAuth)
|
TurnAsyncSocket::doSetUsernameAndPassword(Data&& username, Data&& password, bool shortTermAuth)
|
||||||
{
|
{
|
||||||
mUsername = *username;
|
mUsername = std::move(username);
|
||||||
mPassword = *password;
|
|
||||||
if(shortTermAuth)
|
if(shortTermAuth)
|
||||||
{
|
{
|
||||||
// If we are using short term auth, then use short term password as HMAC key
|
// If we are using short term auth, then use short term password as HMAC key
|
||||||
mHmacKey = *password;
|
mHmacKey = password;
|
||||||
}
|
}
|
||||||
delete username;
|
mPassword = std::move(password);
|
||||||
delete password;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TurnAsyncSocket::setLocalPassword(const char* password)
|
TurnAsyncSocket::setLocalPassword(const char* password)
|
||||||
{
|
{
|
||||||
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=] { doSetLocalPassword(new Data(password)); }));
|
Data password_copy{password};
|
||||||
|
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=, this]() mutable { doSetLocalPassword(std::move(password_copy)); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TurnAsyncSocket::doSetLocalPassword(Data* password)
|
TurnAsyncSocket::doSetLocalPassword(Data&& password)
|
||||||
{
|
{
|
||||||
mLocalHmacKey = *password;
|
mLocalHmacKey = std::move(password);
|
||||||
delete password;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -151,7 +151,7 @@ void
|
|||||||
TurnAsyncSocket::connectivityCheck(const StunTuple& targetAddr, uint32_t peerRflxPriority, bool setIceControlling, bool setIceControlled, unsigned int numRetransmits, unsigned int retrans_iterval_ms)
|
TurnAsyncSocket::connectivityCheck(const StunTuple& targetAddr, uint32_t peerRflxPriority, bool setIceControlling, bool setIceControlled, unsigned int numRetransmits, unsigned int retrans_iterval_ms)
|
||||||
{
|
{
|
||||||
resip_assert(setIceControlling || setIceControlled);
|
resip_assert(setIceControlling || setIceControlled);
|
||||||
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=] { doConnectivityCheck(new StunTuple(targetAddr.getTransportType(), targetAddr.getAddress(), targetAddr.getPort()), peerRflxPriority, setIceControlling, setIceControlled, numRetransmits, retrans_iterval_ms); }));
|
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=, this] { doConnectivityCheck(new StunTuple(targetAddr.getTransportType(), targetAddr.getAddress(), targetAddr.getPort()), peerRflxPriority, setIceControlling, setIceControlled, numRetransmits, retrans_iterval_ms); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -182,7 +182,7 @@ TurnAsyncSocket::createAllocation(unsigned int lifetimeSecs,
|
|||||||
uint64_t reservationToken,
|
uint64_t reservationToken,
|
||||||
StunTuple::TransportType requestedTransportType)
|
StunTuple::TransportType requestedTransportType)
|
||||||
{
|
{
|
||||||
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=] { doCreateAllocation(lifetimeSecs, bandwidth, requestedProps, reservationToken, requestedTransportType); }));
|
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=, this] { doCreateAllocation(lifetimeSecs, bandwidth, requestedProps, reservationToken, requestedTransportType); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -273,7 +273,7 @@ TurnAsyncSocket::doCreateAllocation(unsigned int lifetimeSecs,
|
|||||||
void
|
void
|
||||||
TurnAsyncSocket::refreshAllocation(unsigned int lifetimeSecs)
|
TurnAsyncSocket::refreshAllocation(unsigned int lifetimeSecs)
|
||||||
{
|
{
|
||||||
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=] { doRefreshAllocation(lifetimeSecs); }));
|
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=, this] { doRefreshAllocation(lifetimeSecs); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -323,7 +323,7 @@ TurnAsyncSocket::doDestroyAllocation()
|
|||||||
void
|
void
|
||||||
TurnAsyncSocket::setActiveDestination(const asio::ip::address& address, unsigned short port)
|
TurnAsyncSocket::setActiveDestination(const asio::ip::address& address, unsigned short port)
|
||||||
{
|
{
|
||||||
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=] { doSetActiveDestination(address, port); }));
|
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=, this] { doSetActiveDestination(address, port); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1085,13 +1085,13 @@ TurnAsyncSocket::sendTo(const asio::ip::address& address, unsigned short port, c
|
|||||||
void
|
void
|
||||||
TurnAsyncSocket::sendFramed(const std::shared_ptr<DataBuffer>& data)
|
TurnAsyncSocket::sendFramed(const std::shared_ptr<DataBuffer>& data)
|
||||||
{
|
{
|
||||||
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=] { doSendFramed(data); }));
|
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=, this] { doSendFramed(data); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TurnAsyncSocket::sendToFramed(const asio::ip::address& address, unsigned short port, const std::shared_ptr<DataBuffer>& data)
|
TurnAsyncSocket::sendToFramed(const asio::ip::address& address, unsigned short port, const std::shared_ptr<DataBuffer>& data)
|
||||||
{
|
{
|
||||||
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=] { doSendToFramed(address, port, data); }));
|
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=, this] { doSendToFramed(address, port, data); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1171,14 +1171,14 @@ TurnAsyncSocket::sendToRemotePeer(RemotePeer& remotePeer, const std::shared_ptr<
|
|||||||
void
|
void
|
||||||
TurnAsyncSocket::setSoftware(const char* software)
|
TurnAsyncSocket::setSoftware(const char* software)
|
||||||
{
|
{
|
||||||
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=] { doSetSoftware(new Data(software)); }));
|
Data software_copy{software};
|
||||||
|
asio::dispatch(mIOService, weak_bind<AsyncSocketBase, void()>(mAsyncSocketBase.shared_from_this(), [=, this]() mutable { doSetSoftware(std::move(software_copy)); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TurnAsyncSocket::doSetSoftware(Data* software)
|
TurnAsyncSocket::doSetSoftware(Data&& software)
|
||||||
{
|
{
|
||||||
mSoftware = *software;
|
mSoftware = std::move(software);
|
||||||
delete software;
|
|
||||||
|
|
||||||
const uint32_t unpaddedSize = (unsigned int)mSoftware.size();
|
const uint32_t unpaddedSize = (unsigned int)mSoftware.size();
|
||||||
if(unpaddedSize > 0)
|
if(unpaddedSize > 0)
|
||||||
|
|||||||
@@ -227,9 +227,9 @@ private:
|
|||||||
void channelBindingTimerExpired(const asio::error_code& e, unsigned short channel);
|
void channelBindingTimerExpired(const asio::error_code& e, unsigned short channel);
|
||||||
|
|
||||||
void doRequestSharedSecret();
|
void doRequestSharedSecret();
|
||||||
void doSetUsernameAndPassword(resip::Data* username, resip::Data* password, bool shortTermAuth);
|
void doSetUsernameAndPassword(resip::Data&& username, resip::Data&& password, bool shortTermAuth);
|
||||||
void doSetLocalPassword(resip::Data* password);
|
void doSetLocalPassword(resip::Data&& password);
|
||||||
void doSetSoftware(resip::Data* software);
|
void doSetSoftware(resip::Data&& software);
|
||||||
void doBindRequest();
|
void doBindRequest();
|
||||||
void doConnectivityCheck(StunTuple* targetAddr, uint32_t peerRflxPriority, bool setIceControlling, bool setIceControlled, unsigned int numRetransmits, unsigned int retrans_iterval_ms);
|
void doConnectivityCheck(StunTuple* targetAddr, uint32_t peerRflxPriority, bool setIceControlling, bool setIceControlled, unsigned int numRetransmits, unsigned int retrans_iterval_ms);
|
||||||
void doCreateAllocation(unsigned int lifetime = UnspecifiedLifetime,
|
void doCreateAllocation(unsigned int lifetime = UnspecifiedLifetime,
|
||||||
|
|||||||
Reference in New Issue
Block a user