| Index: webrtc/p2p/base/turnserver.cc
|
| diff --git a/webrtc/p2p/base/turnserver.cc b/webrtc/p2p/base/turnserver.cc
|
| index b4510e637fa6c9273342eda4966052fbaf7a5d15..7dd9e19f63d0f9abd5268218d3210d84f01ab33b 100644
|
| --- a/webrtc/p2p/base/turnserver.cc
|
| +++ b/webrtc/p2p/base/turnserver.cc
|
| @@ -10,6 +10,8 @@
|
|
|
| #include "webrtc/p2p/base/turnserver.h"
|
|
|
| +#include <tuple> // for std::tie
|
| +
|
| #include "webrtc/p2p/base/asyncstuntcpsocket.h"
|
| #include "webrtc/p2p/base/common.h"
|
| #include "webrtc/p2p/base/packetsocketfactory.h"
|
| @@ -124,11 +126,6 @@ TurnServer::TurnServer(rtc::Thread* thread)
|
| }
|
|
|
| TurnServer::~TurnServer() {
|
| - for (AllocationMap::iterator it = allocations_.begin();
|
| - it != allocations_.end(); ++it) {
|
| - delete it->second;
|
| - }
|
| -
|
| for (InternalSocketMap::iterator it = server_sockets_.begin();
|
| it != server_sockets_.end(); ++it) {
|
| rtc::AsyncPacketSocket* socket = it->first;
|
| @@ -429,7 +426,7 @@ bool TurnServer::ValidateNonce(const std::string& nonce) const {
|
|
|
| TurnServerAllocation* TurnServer::FindAllocation(TurnServerConnection* conn) {
|
| AllocationMap::const_iterator it = allocations_.find(*conn);
|
| - return (it != allocations_.end()) ? it->second : NULL;
|
| + return (it != allocations_.end()) ? it->second.get() : nullptr;
|
| }
|
|
|
| TurnServerAllocation* TurnServer::CreateAllocation(TurnServerConnection* conn,
|
| @@ -445,7 +442,7 @@ TurnServerAllocation* TurnServer::CreateAllocation(TurnServerConnection* conn,
|
| TurnServerAllocation* allocation = new TurnServerAllocation(this,
|
| thread_, *conn, external_socket, key);
|
| allocation->SignalDestroyed.connect(this, &TurnServer::OnAllocationDestroyed);
|
| - allocations_[*conn] = allocation;
|
| + allocations_[*conn].reset(allocation);
|
| return allocation;
|
| }
|
|
|
| @@ -518,8 +515,10 @@ void TurnServer::OnAllocationDestroyed(TurnServerAllocation* allocation) {
|
| }
|
|
|
| AllocationMap::iterator it = allocations_.find(*(allocation->conn()));
|
| - if (it != allocations_.end())
|
| + if (it != allocations_.end()) {
|
| + it->second.release();
|
| allocations_.erase(it);
|
| + }
|
| }
|
|
|
| void TurnServer::DestroyInternalSocket(rtc::AsyncPacketSocket* socket) {
|
| @@ -547,7 +546,7 @@ bool TurnServerConnection::operator==(const TurnServerConnection& c) const {
|
| }
|
|
|
| bool TurnServerConnection::operator<(const TurnServerConnection& c) const {
|
| - return src_ < c.src_ || dst_ < c.dst_ || proto_ < c.proto_;
|
| + return std::tie(src_, dst_, proto_) < std::tie(c.src_, c.dst_, c.proto_);
|
| }
|
|
|
| std::string TurnServerConnection::ToString() const {
|
|
|