mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix a race condition with TrustedPublisherServer:
There was a race condition in `on_accept` where the object's destructor could run while `on_accept` was called. This patch ensures that if `on_accept` is called then the object remains valid for the duration of the call.
This commit is contained in:
@@ -31,16 +31,16 @@ namespace test {
|
||||
|
||||
class DatabaseDownloader_test : public beast::unit_test::suite
|
||||
{
|
||||
TrustedPublisherServer
|
||||
std::shared_ptr<TrustedPublisherServer>
|
||||
createServer(jtx::Env& env, bool ssl = true)
|
||||
{
|
||||
std::vector<TrustedPublisherServer::Validator> list;
|
||||
list.push_back(TrustedPublisherServer::randomValidator());
|
||||
return TrustedPublisherServer{
|
||||
return make_TrustedPublisherServer(
|
||||
env.app().getIOService(),
|
||||
list,
|
||||
env.timeKeeper().now() + std::chrono::seconds{3600},
|
||||
ssl};
|
||||
ssl);
|
||||
}
|
||||
|
||||
struct DownloadCompleter
|
||||
@@ -129,8 +129,8 @@ class DatabaseDownloader_test : public beast::unit_test::suite
|
||||
// initiate the download and wait for the callback
|
||||
// to be invoked
|
||||
auto stat = downloader->download(
|
||||
server.local_endpoint().address().to_string(),
|
||||
std::to_string(server.local_endpoint().port()),
|
||||
server->local_endpoint().address().to_string(),
|
||||
std::to_string(server->local_endpoint().port()),
|
||||
"/textfile",
|
||||
11,
|
||||
data.file(),
|
||||
@@ -196,9 +196,9 @@ class DatabaseDownloader_test : public beast::unit_test::suite
|
||||
ripple::test::detail::FileDirGuard const datafile{
|
||||
*this, "downloads", "data", "", false, false};
|
||||
auto server = createServer(env);
|
||||
auto host = server.local_endpoint().address().to_string();
|
||||
auto port = std::to_string(server.local_endpoint().port());
|
||||
server.stop();
|
||||
auto host = server->local_endpoint().address().to_string();
|
||||
auto port = std::to_string(server->local_endpoint().port());
|
||||
server->stop();
|
||||
BEAST_EXPECT(dl->download(
|
||||
host,
|
||||
port,
|
||||
@@ -220,8 +220,8 @@ class DatabaseDownloader_test : public beast::unit_test::suite
|
||||
*this, "downloads", "data", "", false, false};
|
||||
auto server = createServer(env, false);
|
||||
BEAST_EXPECT(dl->download(
|
||||
server.local_endpoint().address().to_string(),
|
||||
std::to_string(server.local_endpoint().port()),
|
||||
server->local_endpoint().address().to_string(),
|
||||
std::to_string(server->local_endpoint().port()),
|
||||
"",
|
||||
11,
|
||||
datafile.file(),
|
||||
@@ -240,8 +240,8 @@ class DatabaseDownloader_test : public beast::unit_test::suite
|
||||
*this, "downloads", "data", "", false, false};
|
||||
auto server = createServer(env);
|
||||
BEAST_EXPECT(dl->download(
|
||||
server.local_endpoint().address().to_string(),
|
||||
std::to_string(server.local_endpoint().port()),
|
||||
server->local_endpoint().address().to_string(),
|
||||
std::to_string(server->local_endpoint().port()),
|
||||
"/textfile/huge",
|
||||
11,
|
||||
datafile.file(),
|
||||
|
||||
Reference in New Issue
Block a user