aboutsummaryrefslogtreecommitdiff
path: root/talk/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
commite749c9ebdb2eb2a519c72c827e70107cbc56d270 (patch)
treeb0bf28e0293c6d1b3a189558db0664b41d59025f /talk/media/sctp/sctpdataengine.cc
parent8f690bc222aa484744eb6d97f4df241b4bd01c1b (diff)
downloadwebrtc-e749c9ebdb2eb2a519c72c827e70107cbc56d270.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@5545 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'talk/media/sctp/sctpdataengine.cc')
-rw-r--r--talk/media/sctp/sctpdataengine.cc37
1 files changed, 20 insertions, 17 deletions
diff --git a/talk/media/sctp/sctpdataengine.cc b/talk/media/sctp/sctpdataengine.cc
index 59e252aaee..aae3d93d07 100644
--- a/talk/media/sctp/sctpdataengine.cc
+++ b/talk/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) {