Skip to content
Snippets Groups Projects
Commit 7201cc52 authored by Adrien Béraud's avatar Adrien Béraud Committed by Gerrit Code Review
Browse files

sips/ice: properly report all incoming packets before closing

Refs #69371

Change-Id: Ife39e493848f1326234d25f657b49734e8ce0b1d
parent 255d7877
No related branches found
No related tags found
No related merge requests found
......@@ -658,6 +658,7 @@ SipsIceTransport::setup()
void
SipsIceTransport::handleEvents()
{
{
std::lock_guard<std::mutex> l(rxMtx_);
while (not rxPending_.empty()) {
......@@ -686,6 +687,8 @@ SipsIceTransport::handleEvents()
}
}
}
rxCv_.notify_all();
}
void
SipsIceTransport::loop()
......@@ -766,7 +769,7 @@ SipsIceTransport::loop()
rxPending_.splice(rxPending_.end(), rxPendingPool_, rxPendingPool_.begin());
} else if (decrypted_size == 0) {
/* EOF */
shutdown();
tlsThread_.stop();
break;
} else if (decrypted_size == GNUTLS_E_AGAIN or
decrypted_size == GNUTLS_E_INTERRUPTED) {
......@@ -821,7 +824,14 @@ SipsIceTransport::clean()
cookie_key_.data = nullptr;
cookie_key_.size = 0;
}
{
// make sure all incoming packets are reported before closing
std::unique_lock<std::mutex> l(rxMtx_);
rxCv_.wait(l, [&](){
return rxPending_.empty();
});
rxPendingPool_.clear();
}
bool event = state_ == TlsConnectionState::ESTABLISHED;
closeTlsSession();
......
......@@ -164,6 +164,7 @@ private:
std::mutex outputBuffMtx_;
std::mutex rxMtx_;
std::condition_variable_any rxCv_;
std::list<std::vector<uint8_t>> rxPending_;
std::list<std::vector<uint8_t>> rxPendingPool_;
pjsip_rx_data rdata_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment