summaryrefslogtreecommitdiff
path: root/media/sctp/sctpdataengine.cc
diff options
context:
space:
mode:
Diffstat (limited to 'media/sctp/sctpdataengine.cc')
-rw-r--r--media/sctp/sctpdataengine.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/media/sctp/sctpdataengine.cc b/media/sctp/sctpdataengine.cc
index 46b2ece..3647d21 100644
--- a/media/sctp/sctpdataengine.cc
+++ b/media/sctp/sctpdataengine.cc
@@ -277,18 +277,20 @@ SctpDataEngine::SctpDataEngine() {
}
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.";
- // }
- // }
+ usrsctp_engines_count--;
+ LOG(LS_VERBOSE) << "usrsctp_engines_count:" << usrsctp_engines_count;
+
+ if (usrsctp_engines_count == 0) {
+ // usrsctp_finish() may fail if it's called too soon after the channels are
+ // closed. Wait and try again until it succeeds for up to 3 seconds.
+ for (size_t i = 0; i < 300; ++i) {
+ if (usrsctp_finish() == 0)
+ return;
+
+ talk_base::Thread::SleepMs(10);
+ }
+ LOG(LS_ERROR) << "Failed to shutdown usrsctp.";
+ }
}
DataMediaChannel* SctpDataEngine::CreateChannel(