mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-04 01:06:48 +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:
@@ -190,8 +190,8 @@ public:
|
||||
BasicApp worker{1};
|
||||
using namespace std::chrono_literals;
|
||||
NetClock::time_point const expiration{3600s};
|
||||
TrustedPublisherServer server{
|
||||
worker.get_io_service(), validators, expiration, false, 1, false};
|
||||
auto server = make_TrustedPublisherServer(
|
||||
worker.get_io_service(), validators, expiration, false, 1, false);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Publisher list site unavailable
|
||||
@@ -206,7 +206,7 @@ public:
|
||||
envconfig([&](std::unique_ptr<Config> cfg) {
|
||||
cfg->section(SECTION_VALIDATOR_LIST_SITES).append(siteURI);
|
||||
cfg->section(SECTION_VALIDATOR_LIST_KEYS)
|
||||
.append(strHex(server.publisherPublic()));
|
||||
.append(strHex(server->publisherPublic()));
|
||||
return cfg;
|
||||
}),
|
||||
};
|
||||
@@ -245,7 +245,7 @@ public:
|
||||
BEAST_EXPECT(!jp.isMember(jss::version));
|
||||
BEAST_EXPECT(
|
||||
jp[jss::pubkey_publisher] ==
|
||||
strHex(server.publisherPublic()));
|
||||
strHex(server->publisherPublic()));
|
||||
}
|
||||
BEAST_EXPECT(jrr[jss::signing_keys].size() == 0);
|
||||
}
|
||||
@@ -264,10 +264,10 @@ public:
|
||||
//----------------------------------------------------------------------
|
||||
// Publisher list site available
|
||||
{
|
||||
server.start();
|
||||
server->start();
|
||||
|
||||
std::stringstream uri;
|
||||
uri << "http://" << server.local_endpoint() << "/validators";
|
||||
uri << "http://" << server->local_endpoint() << "/validators";
|
||||
auto siteURI = uri.str();
|
||||
|
||||
Env env{
|
||||
@@ -275,7 +275,7 @@ public:
|
||||
envconfig([&](std::unique_ptr<Config> cfg) {
|
||||
cfg->section(SECTION_VALIDATOR_LIST_SITES).append(siteURI);
|
||||
cfg->section(SECTION_VALIDATOR_LIST_KEYS)
|
||||
.append(strHex(server.publisherPublic()));
|
||||
.append(strHex(server->publisherPublic()));
|
||||
return cfg;
|
||||
}),
|
||||
};
|
||||
@@ -333,7 +333,7 @@ public:
|
||||
BEAST_EXPECT(jp[jss::seq].asUInt() == 1);
|
||||
BEAST_EXPECT(
|
||||
jp[jss::pubkey_publisher] ==
|
||||
strHex(server.publisherPublic()));
|
||||
strHex(server->publisherPublic()));
|
||||
BEAST_EXPECT(jp[jss::expiration] == to_string(expiration));
|
||||
BEAST_EXPECT(jp[jss::version] == 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user