h2load: Fix failed stream count is added multiple times
The number of failed stream is counted multiple times if several connection attempts are made.
This commit is contained in:
parent
479e15469c
commit
52ff158f34
|
@ -161,12 +161,19 @@ int Client::connect()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::disconnect()
|
void Client::fail()
|
||||||
{
|
{
|
||||||
process_abandoned_streams();
|
process_abandoned_streams();
|
||||||
|
|
||||||
if(worker->stats.req_done == worker->stats.req_todo) {
|
if(worker->stats.req_done == worker->stats.req_todo) {
|
||||||
worker->schedule_terminate();
|
worker->schedule_terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Client::disconnect()
|
||||||
|
{
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
streams.clear();
|
streams.clear();
|
||||||
session.reset();
|
session.reset();
|
||||||
|
@ -353,7 +360,7 @@ void Worker::run()
|
||||||
for(auto& client : clients) {
|
for(auto& client : clients) {
|
||||||
if(client->connect() != 0) {
|
if(client->connect() != 0) {
|
||||||
std::cerr << "client could not connect to host" << std::endl;
|
std::cerr << "client could not connect to host" << std::endl;
|
||||||
client->disconnect();
|
client->fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event_base_loop(evbase, 0);
|
event_base_loop(evbase, 0);
|
||||||
|
@ -419,7 +426,7 @@ void eventcb(bufferevent *bev, short events, void *ptr)
|
||||||
|
|
||||||
if(!next_proto) {
|
if(!next_proto) {
|
||||||
debug_nextproto_error();
|
debug_nextproto_error();
|
||||||
client->disconnect();
|
client->fail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,12 +442,12 @@ void eventcb(bufferevent *bev, short events, void *ptr)
|
||||||
spdy_version);
|
spdy_version);
|
||||||
} else {
|
} else {
|
||||||
debug_nextproto_error();
|
debug_nextproto_error();
|
||||||
client->disconnect();
|
client->fail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else // !HAVE_SPDYLAY
|
#else // !HAVE_SPDYLAY
|
||||||
debug_nextproto_error();
|
debug_nextproto_error();
|
||||||
client->disconnect();
|
client->fail();
|
||||||
return;
|
return;
|
||||||
#endif // !HAVE_SPDYLAY
|
#endif // !HAVE_SPDYLAY
|
||||||
}
|
}
|
||||||
|
@ -477,7 +484,7 @@ void eventcb(bufferevent *bev, short events, void *ptr)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(events & BEV_EVENT_EOF) {
|
if(events & BEV_EVENT_EOF) {
|
||||||
client->disconnect();
|
client->fail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(events & (BEV_EVENT_ERROR | BEV_EVENT_TIMEOUT)) {
|
if(events & (BEV_EVENT_ERROR | BEV_EVENT_TIMEOUT)) {
|
||||||
|
@ -489,7 +496,7 @@ void eventcb(bufferevent *bev, short events, void *ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug("error/eof\n");
|
debug("error/eof\n");
|
||||||
client->disconnect();
|
client->fail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -502,7 +509,7 @@ void readcb(bufferevent *bev, void *ptr)
|
||||||
auto client = static_cast<Client*>(ptr);
|
auto client = static_cast<Client*>(ptr);
|
||||||
rv = client->on_read();
|
rv = client->on_read();
|
||||||
if(rv != 0) {
|
if(rv != 0) {
|
||||||
client->disconnect();
|
client->fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -517,7 +524,7 @@ void writecb(bufferevent *bev, void *ptr)
|
||||||
auto client = static_cast<Client*>(ptr);
|
auto client = static_cast<Client*>(ptr);
|
||||||
rv = client->on_write();
|
rv = client->on_write();
|
||||||
if(rv != 0) {
|
if(rv != 0) {
|
||||||
client->disconnect();
|
client->fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -151,6 +151,7 @@ struct Client {
|
||||||
~Client();
|
~Client();
|
||||||
int connect();
|
int connect();
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
void fail();
|
||||||
void submit_request();
|
void submit_request();
|
||||||
void process_abandoned_streams();
|
void process_abandoned_streams();
|
||||||
void report_progress();
|
void report_progress();
|
||||||
|
|
Loading…
Reference in New Issue