wsperf won't set a timer when timeout=0

This commit is contained in:
Peter Thorson
2012-03-10 16:19:37 -06:00
parent 338ac2a574
commit 4903edbe30
4 changed files with 24 additions and 20 deletions

View File

@@ -68,19 +68,22 @@ case_handler::case_handler(wscmd::cmd& cmd) {
/// Starts a test by starting the timeout timer and marking the start time
void case_handler::start(connection_ptr con, uint64_t timeout) {
m_timer.reset(new boost::asio::deadline_timer(
con->get_io_service(),
boost::posix_time::seconds(0))
);
m_timer->expires_from_now(boost::posix_time::milliseconds(timeout));
m_timer->async_wait(
boost::bind(
&type::on_timer,
this,
con,
boost::asio::placeholders::error
)
);
if (timeout > 0) {
m_timer.reset(new boost::asio::deadline_timer(
con->get_io_service(),
boost::posix_time::seconds(0))
);
m_timer->expires_from_now(boost::posix_time::milliseconds(timeout));
m_timer->async_wait(
boost::bind(
&type::on_timer,
this,
con,
boost::asio::placeholders::error
)
);
}
m_start = boost::chrono::steady_clock::now();
}
@@ -106,6 +109,8 @@ void case_handler::end(connection_ptr con) {
double total = 0;
double seconds = 0;
m_timer->cancel();
// TODO: handle weird sizes and error conditions better
if (m_end.size() > m_quantile_count) {
boost::chrono::steady_clock::time_point last = m_start;