diff --git a/src/jamidht/channeled_transport.cpp b/src/jamidht/channeled_transport.cpp index 8d480b302f2ff482e765dab32740642b7a53a96a..186b90155c9f81252d92514b61a51dbe9b1628a8 100644 --- a/src/jamidht/channeled_transport.cpp +++ b/src/jamidht/channeled_transport.cpp @@ -292,14 +292,14 @@ ChanneledSIPTransport::send(pjsip_tx_data* tdata, // Check in we are able to send it in synchronous way first const std::size_t size = tdata->buf.cur - tdata->buf.start; std::unique_lock<std::mutex> lk {txMutex_}; - if (/*TODO handle disconned: syncTx_ and*/ txQueue_.empty()) { - std::error_code ec; - socket_->write(reinterpret_cast<const uint8_t*>(tdata->buf.start), size, ec); - lk.unlock(); - if (ec) { - return PJ_EINVAL; + if (txQueue_.empty()) { + if (socket_) { + std::error_code ec; + socket_->write(reinterpret_cast<const uint8_t*>(tdata->buf.start), size, ec); + if (!ec) + return PJ_SUCCESS; } - return PJ_SUCCESS; + return PJ_EINVAL; } // Asynchronous sending