in src/cpp/RiderLink/Source/RD/src/rd_framework_cpp/src/main/wire/SocketWire.cpp [124:167]
void SocketWire::Base::set_socket_provider(std::shared_ptr<CActiveSocket> new_socket)
{
{
std::lock_guard<decltype(socket_send_lock)> guard(socket_send_lock);
socket_provider = std::move(new_socket);
socket_send_var.notify_all();
}
{
std::lock_guard<decltype(lock)> guard(lock);
if (lifetimeDef.lifetime->is_terminated())
{
return;
}
}
auto heartbeat = LifetimeDefinition::use([this](Lifetime heartbeatLifetime) {
const auto heartbeat = start_heartbeat(heartbeatLifetime).share();
async_send_buffer.resume();
connected.set(true);
receiverProc();
connected.set(false);
async_send_buffer.pause("Disconnected");
return heartbeat;
});
const auto status = heartbeat.wait_for(timeout);
logger->debug("{}: waited for heartbeat to stop with status: {}", this->id, static_cast<uint32_t>(status));
if (!socket_provider->IsSocketValid())
{
logger->debug("{}: socket was already shut down", this->id);
}
else if (!socket_provider->Shutdown(CSimpleSocket::Both))
{
// double close?
logger->warn("{}: possibly double close after disconnect", this->id);
}
}