From 95392e64bac01624fe7afa3cafbd39a5ec85ee5f Mon Sep 17 00:00:00 2001 From: "pwestin@webrtc.org" Date: Wed, 8 Feb 2012 08:08:37 +0000 Subject: [PATCH] Bugfix EnableIPV6 issue 255 Review URL: https://webrtc-codereview.appspot.com/378005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1633 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../source/udp_transport_impl.cc | 33 +++++++++---------- .../udp_transport/source/udp_transport_impl.h | 3 +- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/modules/udp_transport/source/udp_transport_impl.cc b/src/modules/udp_transport/source/udp_transport_impl.cc index b931bfe900..7df0af349b 100644 --- a/src/modules/udp_transport/source/udp_transport_impl.cc +++ b/src/modules/udp_transport/source/udp_transport_impl.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -117,7 +117,6 @@ UdpTransportImpl::UdpTransportImpl(const WebRtc_Word32 id, _useSetSockOpt(false), _qos(false), _pcp(0), - _IpV6EnabledRead(false), _ipV6Enabled(false), _serviceType(0), _overrideDSCP(0), @@ -1075,22 +1074,21 @@ bool UdpTransportImpl::SetSockOptUsed() return _useSetSockOpt; } -WebRtc_Word32 UdpTransportImpl::EnableIpV6() -{ - WEBRTC_TRACE(kTraceModuleCall, kTraceTransport, _id, "%s", __FUNCTION__); - CriticalSectionScoped cs(_crit); - if(_IpV6EnabledRead) - { - if(_ipV6Enabled) - { - return 0; - }else { - _lastError = kIpVersion6Error; - return -1; - } - } - _ipV6Enabled=true; +WebRtc_Word32 UdpTransportImpl::EnableIpV6() { + WEBRTC_TRACE(kTraceModuleCall, kTraceTransport, _id, "%s", __FUNCTION__); + + CriticalSectionScoped cs(_crit); + const bool initialized = (_ptrSendRtpSocket || _ptrRtpSocket); + + if (_ipV6Enabled) { return 0; + } + if (initialized) { + _lastError = kIpVersion6Error; + return -1; + } + _ipV6Enabled = true; + return 0; } WebRtc_Word32 UdpTransportImpl::FilterIP( @@ -1208,7 +1206,6 @@ bool UdpTransportImpl::SourcePortsInitialized() const bool UdpTransportImpl::IpV6Enabled() const { WEBRTC_TRACE(kTraceStream, kTraceTransport, _id, "%s", __FUNCTION__); - _IpV6EnabledRead=true; return _ipV6Enabled; } diff --git a/src/modules/udp_transport/source/udp_transport_impl.h b/src/modules/udp_transport/source/udp_transport_impl.h index 7e0cd1bfeb..52a34bd494 100644 --- a/src/modules/udp_transport/source/udp_transport_impl.h +++ b/src/modules/udp_transport/source/udp_transport_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -224,7 +224,6 @@ private: bool _useSetSockOpt; bool _qos; WebRtc_Word32 _pcp; - mutable bool _IpV6EnabledRead; bool _ipV6Enabled; WebRtc_Word32 _serviceType; WebRtc_Word32 _overrideDSCP;