h2load: Fix crash when dealing connection: close with HTTP/1.1 server

This commit is contained in:
Tatsuhiro Tsujikawa 2015-11-26 21:26:00 +09:00
parent faad041868
commit 8e06e37375
2 changed files with 25 additions and 5 deletions

View File

@ -360,12 +360,23 @@ void Client::fail() {
if (new_connection_requested) { if (new_connection_requested) {
new_connection_requested = false; new_connection_requested = false;
if (req_started < req_todo) {
// At the moment, we don't have a facility to re-start request
// already in in-flight. Make them fail.
auto req_abandoned = req_started - req_done;
// Keep using current address worker->stats.req_failed += req_abandoned;
if (connect() == 0) { worker->stats.req_error += req_abandoned;
return; worker->stats.req_done += req_abandoned;
req_done = req_started;
// Keep using current address
if (connect() == 0) {
return;
}
std::cerr << "client could not connect to host" << std::endl;
} }
std::cerr << "client could not connect to host" << std::endl;
} }
process_abandoned_streams(); process_abandoned_streams();
@ -377,6 +388,7 @@ void Client::disconnect() {
ev_timer_stop(worker->loop, &request_timeout_watcher); ev_timer_stop(worker->loop, &request_timeout_watcher);
streams.clear(); streams.clear();
session.reset(); session.reset();
wb.reset();
state = CLIENT_IDLE; state = CLIENT_IDLE;
ev_io_stop(worker->loop, &wev); ev_io_stop(worker->loop, &wev);
ev_io_stop(worker->loop, &rev); ev_io_stop(worker->loop, &rev);

View File

@ -51,7 +51,15 @@ Http1Session::~Http1Session() {}
namespace { namespace {
// HTTP response message begin // HTTP response message begin
int htp_msg_begincb(http_parser *htp) { return 0; } int htp_msg_begincb(http_parser *htp) {
auto session = static_cast<Http1Session *>(htp->data);
if (session->stream_resp_counter_ >= session->stream_req_counter_) {
return -1;
}
return 0;
}
} // namespace } // namespace
namespace { namespace {