Porting the changes done to UE5 to fix the recording leak to UE4

The slowdown is considerably more noticeable here since the engine runs much smoother. This makes evident that this is a stopgap measure, and should be looked into further down the line.
This commit is contained in:
Jorge Virgos 2024-09-12 12:07:54 +02:00 committed by Blyron
parent 9e94feb3a5
commit 4d09f0a660
2 changed files with 3 additions and 14 deletions

View File

@ -15,7 +15,6 @@
#include <boost/asio/connect.hpp>
#include <boost/asio/read.hpp>
#include <boost/asio/write.hpp>
#include <boost/asio/post.hpp>
#include <boost/asio/bind_executor.hpp>
#include <exception>
@ -86,7 +85,6 @@ namespace tcp {
void Client::Connect() {
auto self = shared_from_this();
boost::asio::post(_strand, [this, self]() {
if (_done) {
return;
}
@ -139,18 +137,15 @@ namespace tcp {
log_debug("streaming client: connecting to", ep);
_socket.async_connect(ep, boost::asio::bind_executor(_strand, handle_connect));
});
}
void Client::Stop() {
_connection_timer.cancel();
auto self = shared_from_this();
boost::asio::post(_strand, [this, self]() {
_done = true;
if (_socket.is_open()) {
_socket.close();
}
});
}
void Client::Reconnect() {
@ -165,7 +160,6 @@ namespace tcp {
void Client::ReadData() {
auto self = shared_from_this();
boost::asio::post(_strand, [this, self]() {
if (_done) {
return;
}
@ -182,7 +176,7 @@ namespace tcp {
// Move the buffer to the callback function and start reading the next
// piece of data.
// log_debug("streaming client: success reading data, calling the callback");
boost::asio::post(_strand, [self, message]() { self->_callback(message->pop()); });
self->_callback(message->pop());
ReadData();
} else {
// As usual, if anything fails start over from the very top.
@ -219,7 +213,6 @@ namespace tcp {
_socket,
message->size_as_buffer(),
boost::asio::bind_executor(_strand, handle_read_header));
});
}
} // namespace tcp

View File

@ -79,7 +79,6 @@ namespace tcp {
DEBUG_ASSERT(message != nullptr);
DEBUG_ASSERT(!message->empty());
auto self = shared_from_this();
boost::asio::post(_strand, [=]() {
if (!_socket.is_open()) {
return;
}
@ -111,11 +110,8 @@ namespace tcp {
log_debug("session", _session_id, ": sending message of", message->size(), "bytes");
_deadline.expires_from_now(_timeout);
boost::asio::async_write(
_socket,
message->GetBufferSequence(),
handle_sent);
});
boost::asio::async_write(_socket, message->GetBufferSequence(),
boost::asio::bind_executor(_strand, handle_sent));
}
void ServerSession::Close() {