Properly shut down the SCTP stack.

TBR phoglund@webrtc.org for the tsan_v2/suppressions.txt change.
R=ldixon@webrtc.org, pthatcher@webrtc.org
TBR=phoglund@webrtc.org
BUG=2749

Review URL: https://webrtc-codereview.appspot.com/12739004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6484 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
jiayl@webrtc.org
2014-06-18 21:30:40 +00:00
parent a19b930b5b
commit f8063d34de
6 changed files with 37 additions and 33 deletions

View File

@@ -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(