Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: webrtc/p2p/base/turnserver.cc

Issue 2264343002: Fixing segfault caused by TurnServer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« webrtc/p2p/base/turnserver.h ('K') | « webrtc/p2p/base/turnserver.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 if (it != allocations_.end()) { 518 if (it != allocations_.end()) {
519 it->second.release(); 519 it->second.release();
520 allocations_.erase(it); 520 allocations_.erase(it);
521 } 521 }
522 } 522 }
523 523
524 void TurnServer::DestroyInternalSocket(rtc::AsyncPacketSocket* socket) { 524 void TurnServer::DestroyInternalSocket(rtc::AsyncPacketSocket* socket) {
525 InternalSocketMap::iterator iter = server_sockets_.find(socket); 525 InternalSocketMap::iterator iter = server_sockets_.find(socket);
526 if (iter != server_sockets_.end()) { 526 if (iter != server_sockets_.end()) {
527 rtc::AsyncPacketSocket* socket = iter->first; 527 rtc::AsyncPacketSocket* socket = iter->first;
528 server_sockets_.erase(iter);
528 // We must destroy the socket async to avoid invalidating the sigslot 529 // We must destroy the socket async to avoid invalidating the sigslot
529 // callback list iterator inside a sigslot callback. 530 // callback list iterator inside a sigslot callback. (In other words,
530 rtc::Thread::Current()->Dispose(socket); 531 // deleting an object from within a callback from that object).
531 server_sockets_.erase(iter); 532 pending_delete_sockets_.push_back(
533 std::unique_ptr<rtc::AsyncPacketSocket>(socket));
534 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, rtc::Thread::Current(),
535 [this] { pending_delete_sockets_.clear(); });
pthatcher1 2016/08/23 00:36:55 I think the style guide said not to store lambdas.
Taylor Brandstetter 2016/08/23 01:11:20 The Chromium style guide says to never store *capt
pthatcher1 2016/08/23 01:15:32 Ah, thanks for correcting my poor memory.
Taylor Brandstetter 2016/08/23 23:31:12 I'll just bite the bullet, it's only a few extra l
532 } 536 }
533 } 537 }
534 538
535 TurnServerConnection::TurnServerConnection(const rtc::SocketAddress& src, 539 TurnServerConnection::TurnServerConnection(const rtc::SocketAddress& src,
536 ProtocolType proto, 540 ProtocolType proto,
537 rtc::AsyncPacketSocket* socket) 541 rtc::AsyncPacketSocket* socket)
538 : src_(src), 542 : src_(src),
539 dst_(socket->GetRemoteAddress()), 543 dst_(socket->GetRemoteAddress()),
540 proto_(proto), 544 proto_(proto),
541 socket_(socket) { 545 socket_(socket) {
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 MSG_ALLOCATION_TIMEOUT); 957 MSG_ALLOCATION_TIMEOUT);
954 } 958 }
955 959
956 void TurnServerAllocation::Channel::OnMessage(rtc::Message* msg) { 960 void TurnServerAllocation::Channel::OnMessage(rtc::Message* msg) {
957 ASSERT(msg->message_id == MSG_ALLOCATION_TIMEOUT); 961 ASSERT(msg->message_id == MSG_ALLOCATION_TIMEOUT);
958 SignalDestroyed(this); 962 SignalDestroyed(this);
959 delete this; 963 delete this;
960 } 964 }
961 965
962 } // namespace cricket 966 } // namespace cricket
OLDNEW
« webrtc/p2p/base/turnserver.h ('K') | « webrtc/p2p/base/turnserver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698