mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
adds handshake delay and test doneness check
This commit is contained in:
@@ -94,6 +94,11 @@ void request::process(unsigned int id) {
|
||||
|
||||
boost::thread t(boost::bind(&client::run, &e, true));
|
||||
|
||||
size_t handshake_delay;
|
||||
if(!wscmd::extract_number<size_t>(command, "handshake_delay",handshake_delay)) {
|
||||
handshake_delay = 10;
|
||||
}
|
||||
|
||||
// create connections
|
||||
for (size_t i = 0; i < connection_count; i++) {
|
||||
client::connection_ptr con;
|
||||
@@ -103,6 +108,8 @@ void request::process(unsigned int id) {
|
||||
shandler->on_connect(con);
|
||||
|
||||
e.connect(con);
|
||||
|
||||
boost::this_thread::sleep(boost::posix_time::milliseconds(handshake_delay));
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
@@ -111,12 +118,18 @@ void request::process(unsigned int id) {
|
||||
|
||||
// check for too few connections
|
||||
|
||||
shandler->maintenance();
|
||||
bool quit = shandler->maintenance();
|
||||
|
||||
// check for done-ness
|
||||
if (quit) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
e.end_perpetual();
|
||||
t.join();
|
||||
}
|
||||
|
||||
writer->write(prepare_response("test_complete",""));
|
||||
|
||||
@@ -179,15 +179,24 @@ std::string stress_handler::get_data() const {
|
||||
return data.str();
|
||||
}
|
||||
|
||||
void stress_handler::maintenance() {
|
||||
bool stress_handler::maintenance() {
|
||||
std::list<connection_ptr> to_process;
|
||||
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(m_lock);
|
||||
|
||||
bool quit = true;
|
||||
|
||||
std::map<connection_ptr,con_data>::iterator it;
|
||||
for (it = m_con_data.begin(); it != m_con_data.end(); it++) {
|
||||
to_process.push_back((*it).first);
|
||||
if ((*it).first->get_state() != websocketpp::session::state::CLOSED) {
|
||||
quit = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (quit) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,4 +229,6 @@ void stress_handler::maintenance() {
|
||||
close(con);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
void end();
|
||||
|
||||
std::string get_data() const;
|
||||
virtual void maintenance();
|
||||
virtual bool maintenance();
|
||||
protected:
|
||||
size_t m_current_connections;
|
||||
size_t m_max_connections;
|
||||
|
||||
Reference in New Issue
Block a user