summaryrefslogtreecommitdiff
path: root/media/sctp/sctpdataengine.cc
diff options
context:
space:
mode:
authorxians@webrtc.org <xians@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-02-13 15:09:40 +0000
committerxians@webrtc.org <xians@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-02-13 15:09:40 +0000
commit195a757a0e2513706e8622b4c7ab0d57bd993b80 (patch)
tree1397588220e7e9d47ae99106fa37497ab7a15887 /media/sctp/sctpdataengine.cc
parent20477f1f73a6bbb4e9101751c99f705a07843147 (diff)
downloadtalk-195a757a0e2513706e8622b4c7ab0d57bd993b80.tar.gz
Update libjingle to 61514460
TBR=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/8649004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@5545 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'media/sctp/sctpdataengine.cc')
-rw-r--r--media/sctp/sctpdataengine.cc37
1 files changed, 20 insertions, 17 deletions
diff --git a/media/sctp/sctpdataengine.cc b/media/sctp/sctpdataengine.cc
index 59e252a..aae3d93 100644
--- a/media/sctp/sctpdataengine.cc
+++ b/media/sctp/sctpdataengine.cc
@@ -237,8 +237,10 @@ static int OnSctpInboundPacket(struct socket* sock, union sctp_sockstore addr,
// Set the initial value of the static SCTP Data Engines reference count.
int SctpDataEngine::usrsctp_engines_count = 0;
-SctpDataEngine::SctpDataEngine() {
+void SctpDataEngine::AddRefEngine() {
+ LOG(LS_VERBOSE) << "usrsctp_engines_count:" << usrsctp_engines_count;
if (usrsctp_engines_count == 0) {
+ LOG(LS_INFO) << "SctpDataEngine: Initializing usrsctp";
// First argument is udp_encapsulation_port, which is not releveant for our
// AF_CONN use of sctp.
usrsctp_init(0, cricket::OnSctpOutboundPacket, debug_sctp_printf);
@@ -276,26 +278,25 @@ SctpDataEngine::SctpDataEngine() {
cricket::kMaxSctpSid);
}
usrsctp_engines_count++;
+}
- // We don't put in a codec because we don't want one offered when we
- // use the hybrid data engine.
- // codecs_.push_back(cricket::DataCodec( kGoogleSctpDataCodecId,
- // kGoogleSctpDataCodecName, 0));
+void SctpDataEngine::ReleaseEngine() {
+ usrsctp_engines_count--;
+ if (usrsctp_engines_count == 0) {
+ LOG(LS_INFO) << "SctpDataEngine: Shutting down";
+ if (usrsctp_finish() != 0) {
+ LOG_ERRNO(LS_ERROR) << "SctpDataEngine: usrsctp_finish failed: ";
+ }
+ }
+ LOG(LS_VERBOSE) << "usrsctp_engines_count:" << usrsctp_engines_count;
+}
+
+SctpDataEngine::SctpDataEngine() {
+ AddRefEngine();
}
SctpDataEngine::~SctpDataEngine() {
- // TODO(ldixon): There is currently a bug in teardown of usrsctp that blocks
- // indefintely if a finish call made too soon after close calls. So teardown
- // has been skipped. Once the bug is fixed, retest and enable teardown.
- // Tracked in webrtc issue 2749.
- //
- // usrsctp_engines_count--;
- // LOG(LS_VERBOSE) << "usrsctp_engines_count:" << usrsctp_engines_count;
- // if (usrsctp_engines_count == 0) {
- // if (usrsctp_finish() != 0) {
- // LOG(LS_WARNING) << "usrsctp_finish.";
- // }
- // }
+ ReleaseEngine();
}
DataMediaChannel* SctpDataEngine::CreateChannel(
@@ -314,10 +315,12 @@ SctpDataMediaChannel::SctpDataMediaChannel(talk_base::Thread* thread)
sending_(false),
receiving_(false),
debug_name_("SctpDataMediaChannel") {
+ SctpDataEngine::AddRefEngine();
}
SctpDataMediaChannel::~SctpDataMediaChannel() {
CloseSctpSocket();
+ SctpDataEngine::ReleaseEngine();
}
sockaddr_conn SctpDataMediaChannel::GetSctpSockAddr(int port) {