Skip to content

Commit

Permalink
apps/seawreck: Convert to run()
Browse files Browse the repository at this point in the history
  • Loading branch information
tgrabiec committed Aug 28, 2015
1 parent 0e0c46f commit 5259ef2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apps/seawreck/seawreck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ int main(int ac, char** av) {
("reqs,r", bpo::value<unsigned>()->default_value(0), "reqs per connection")
("duration,d", bpo::value<unsigned>()->default_value(10), "duration of the test in seconds)");

return app.run_deprecated(ac, av, [&app] {
return app.run(ac, av, [&app] () -> future<int> {
auto& config = app.configuration();
auto server = config["server"].as<std::string>();
auto reqs_per_conn = config["reqs"].as<unsigned>();
Expand All @@ -183,7 +183,7 @@ int main(int ac, char** av) {

if (total_conn % smp::count != 0) {
print("Error: conn needs to be n * cpu_nr\n");
return engine().exit(0);
return make_ready_future<int>(-1);
}

auto http_clients = new distributed<http_client>;
Expand All @@ -194,7 +194,7 @@ int main(int ac, char** av) {
print("Server: %s\n", server);
print("Connections: %u\n", total_conn);
print("Requests/connection: %s\n", reqs_per_conn == 0 ? "dynamic (timer based)" : std::to_string(reqs_per_conn));
http_clients->start(std::move(duration), std::move(total_conn), std::move(reqs_per_conn)).then([http_clients, started, server] {
return http_clients->start(std::move(duration), std::move(total_conn), std::move(reqs_per_conn)).then([http_clients, started, server] {
return http_clients->invoke_on_all(&http_client::connect, ipv4_addr{server});
}).then([http_clients] {
return http_clients->invoke_on_all(&http_client::run);
Expand All @@ -210,13 +210,13 @@ int main(int ac, char** av) {
print("Total time: %f\n", secs);
print("Requests/sec: %f\n", static_cast<double>(total_reqs) / secs);
print("========== done ============\n");
http_clients->stop().then([http_clients] {
return http_clients->stop().then([http_clients] {
// FIXME: If we call engine().exit(0) here to exit when
// requests are done. The tcp connection will not be closed
// properly, becasue we exit too earily and the FIN packets are
// not exchanged.
delete http_clients;
engine().exit(0);
return make_ready_future<int>(0);
});
});
});
Expand Down

0 comments on commit 5259ef2

Please sign in to comment.