Commit 5da38b22 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

h2load: Fix bug that it did not try to connect to server again

parent ce61f626
......@@ -202,7 +202,9 @@ void readcb(struct ev_loop *loop, ev_io *w, int revents) {
auto client = static_cast<Client *>(w->data);
client->restart_timeout();
if (client->do_read() != 0) {
client->fail();
if (client->try_again_or_fail() == 0) {
return;
}
delete client;
return;
}
......@@ -453,7 +455,7 @@ void Client::restart_timeout() {
}
}
void Client::fail() {
int Client::try_again_or_fail() {
disconnect();
if (new_connection_requested) {
......@@ -471,13 +473,21 @@ void Client::fail() {
// Keep using current address
if (connect() == 0) {
return;
return 0;
}
std::cerr << "client could not connect to host" << std::endl;
}
}
process_abandoned_streams();
return -1;
}
void Client::fail() {
disconnect();
process_abandoned_streams();
}
void Client::disconnect() {
......
......@@ -307,6 +307,12 @@ struct Client {
int connect();
void disconnect();
void fail();
// Call this function when do_read() returns -1. This function
// tries to connect to the remote host again if it is requested. If
// so, this function returns 0, and this object should be retained.
// Otherwise, this function returns -1, and this object should be
// deleted.
int try_again_or_fail();
void timeout();
void restart_timeout();
int submit_request();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment