diff --git a/srtcore/api.cpp b/srtcore/api.cpp index f052c9606..63dab3927 100644 --- a/srtcore/api.cpp +++ b/srtcore/api.cpp @@ -1990,12 +1990,14 @@ int srt::CUDTUnited::close(CUDTSocket* s) HLOGC(smlog.Debug, log << s->core().CONID() << "CLOSING (removing listener immediately)"); s->core().notListening(); + s->m_Status = SRTS_CLOSING; // broadcast all "accept" waiting CSync::lock_notify_all(s->m_AcceptCond, s->m_AcceptLock); } else { + s->m_Status = SRTS_CLOSING; // Note: this call may be done on a socket that hasn't finished // sending all packets scheduled for sending, which means, this call // may block INDEFINITELY. As long as it's acceptable to block the @@ -2118,6 +2120,7 @@ int srt::CUDTUnited::close(CUDTSocket* s) ... } */ + CSync::notify_one_relaxed(m_GCStopCond); return 0; } diff --git a/test/test_reuseaddr.cpp b/test/test_reuseaddr.cpp index 67cf33719..60532eb80 100644 --- a/test/test_reuseaddr.cpp +++ b/test/test_reuseaddr.cpp @@ -428,8 +428,9 @@ void shutdownListener(SRTSOCKET bindsock) EXPECT_NE(srt_setsockopt(bindsock, 0, SRTO_RCVSYN, &yes, sizeof yes), SRT_ERROR); // for async connect EXPECT_NE(srt_close(bindsock), SRT_ERROR); - std::chrono::milliseconds check_period (250); + std::chrono::milliseconds check_period (100); int credit = 400; // 10 seconds + auto then = std::chrono::steady_clock::now(); std::cout << "[T/S] waiting for cleanup of @" << bindsock << " up to 10s" << std::endl; while (srt_getsockstate(bindsock) != SRTS_NONEXIST) @@ -438,10 +439,15 @@ void shutdownListener(SRTSOCKET bindsock) --credit; if (!credit) break; - - //std::cerr << "."; } - //std::cerr << std::endl; + auto now = std::chrono::steady_clock::now(); + auto dur = std::chrono::duration_cast(now - then); + + // Keep as single string because this tends to be mixed from 2 threads. + std::ostringstream sout; + sout << "[T/S] @" << bindsock << " dissolved after " + << (dur.count() / 1000.0) << "s" << std::endl; + std::cout << sout.str() << std::flush; EXPECT_NE(credit, 0); }