First try with something working, still need to clean and test

This commit is contained in:
Nora Shoemaker 2015-07-21 11:28:12 -07:00
parent 52152ad96d
commit 650e463a49
2 changed files with 9 additions and 4 deletions

View File

@ -176,7 +176,7 @@ void second_timeout_w_cb(EV_P_ ev_timer *w, int revents) {
++worker->nconns_made; ++worker->nconns_made;
} }
if (worker->current_second >= std::max((ssize_t)0, (worker->config->seconds - 1))) { if (worker->current_second >= std::max((ssize_t)0, (worker->config->seconds - 1))) {
ev_timer_stop(worker->rate_loop, w); ev_timer_stop(worker->loop, w);
} }
++worker->current_second; ++worker->current_second;
} }
@ -742,11 +742,10 @@ Worker::Worker(uint32_t id, SSL_CTX *ssl_ctx, size_t req_todo, size_t nclients,
if (config->is_rate_mode()) { if (config->is_rate_mode()) {
// create timer that will go off every second // create timer that will go off every second
ev_timer timeout_watcher; //ev_timer timeout_watcher;
timeout_watcher.data = this; timeout_watcher.data = this;
ev_init(&timeout_watcher, second_timeout_w_cb); ev_init(&timeout_watcher, second_timeout_w_cb);
timeout_watcher.repeat = 1.; timeout_watcher.repeat = 1.;
ev_timer_again(rate_loop, &timeout_watcher);
} else { } else {
for (size_t i = 0; i < nclients; ++i) { for (size_t i = 0; i < nclients; ++i) {
auto req_todo = nreqs_per_client; auto req_todo = nreqs_per_client;
@ -775,7 +774,7 @@ void Worker::run() {
} }
} }
} else { } else {
ev_run(rate_loop, 0); ev_timer_again(loop, &timeout_watcher);
} }
ev_run(loop, 0); ev_run(loop, 0);
} }

View File

@ -185,6 +185,12 @@ struct Worker {
uint32_t id; uint32_t id;
bool tls_info_report_done; bool tls_info_report_done;
struct ev_loop *rate_loop; struct ev_loop *rate_loop;
ssize_t current_second;
ssize_t nconns_made;
ssize_t nclients;
ssize_t nreqs_per_client;
ssize_t nreqs_rem;
ev_timer timeout_watcher;
Worker(uint32_t id, SSL_CTX *ssl_ctx, size_t nreq_todo, size_t nclients, Worker(uint32_t id, SSL_CTX *ssl_ctx, size_t nreq_todo, size_t nclients,
Config *config); Config *config);