Skip to content
Snippets Groups Projects
Commit dfb97916 authored by Guillaume Roguez's avatar Guillaume Roguez
Browse files

sips: fix send ack

send ack message was queued in a queue unstacked in
the main thread, but this last is busy by application
waiting for the ack... deadloop!
This patch fixes this by calling the application ack
confirmation callback immediatly when the TLS acknowledge
the ack.

Change-Id: Ic8fe6102acca184d78f86e3e8524382e9b257f4b
Tuleap: #433
parent 0ce4d753
No related branches found
No related tags found
No related merge requests found
......@@ -328,20 +328,6 @@ SipsIceTransport::handleEvents()
}
}
}
// Acknowledged SIP -> TLS packet
decltype(txAckQueue_) ack_queue;
{
std::lock_guard<std::mutex> l(txAckQueueMutex_);
ack_queue = std::move(txAckQueue_);
txAckQueue_.clear();
}
for (const auto& pair: ack_queue) {
auto tdata = pair.first;
tdata->op_key.tdata = nullptr;
if (tdata->op_key.callback)
tdata->op_key.callback(&trData_.base, tdata->op_key.token, pair.second);
}
}
void
......@@ -637,11 +623,13 @@ SipsIceTransport::send(pjsip_tx_data *tdata, const pj_sockaddr_t *rem_addr,
// Asynchronous send
const std::size_t size = tdata->buf.cur - tdata->buf.start;
auto ret = tls_->async_send(tdata->buf.start, size, [=](std::size_t bytes_sent){
auto ret = tls_->async_send(tdata->buf.start, size, [=](std::size_t bytes_sent) {
// WARN: This code is called in the context of the TlsSession thread
if (bytes_sent == 0)
bytes_sent = -PJ_RETURN_OS_ERROR(OSERR_ENOTCONN);
std::lock_guard<std::mutex> l(txAckQueueMutex_);
txAckQueue_.emplace_back(std::make_pair(tdata, bytes_sent));
tdata->op_key.tdata = nullptr;
if (tdata->op_key.callback)
tdata->op_key.callback(&trData_.base, tdata->op_key.token, bytes_sent);
});
// Shutdown on fatal errors
......
......@@ -115,9 +115,6 @@ private:
std::mutex rxMtx_;
std::list<std::vector<uint8_t>> rxPending_;
std::mutex txAckQueueMutex_;
std::list<std::pair<pjsip_tx_data*, ssize_t>> txAckQueue_;
pj_status_t send(pjsip_tx_data*, const pj_sockaddr_t*, int, void*, pjsip_transport_callback);
void handleEvents();
void pushChangeStateEvent(ChangeStateEventData&&);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment