From c4ccc376df75f84db5cd7c884eab89cdd3d9f751 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 28 Mar 2015 20:04:23 +0900 Subject: [PATCH] nghttp: Refactor function names on_SOMETHING should be used only for I/O callback functions --- src/nghttp.cc | 20 ++++++++++---------- src/nghttp.h | 7 +++---- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/nghttp.cc b/src/nghttp.cc index 7298d6d5..de2f936a 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -396,7 +396,7 @@ int submit_request(HttpClient *client, const Headers &headers, Request *req) { } req->stream_id = stream_id; - client->on_request(req); + client->request_done(req); req->req_nva = std::move(build_headers); @@ -418,7 +418,7 @@ void writecb(struct ev_loop *loop, ev_io *w, int revents) { auto client = static_cast(w->data); auto rv = client->do_write(); if (rv == HttpClient::ERR_CONNECT_FAIL) { - client->on_connect_fail(); + client->connect_fail(); return; } if (rv != 0) { @@ -679,7 +679,7 @@ int HttpClient::write_clear() { int HttpClient::noop() { return 0; } -void HttpClient::on_connect_fail() { +void HttpClient::connect_fail() { if (state == ClientState::IDLE) { std::cerr << "[ERROR] Could not connect to the address " << util::numeric_name(cur_addr->ai_addr, cur_addr->ai_addrlen) @@ -732,7 +732,7 @@ int HttpClient::connected() { return do_write(); } - if (on_connect() != 0) { + if (connection_made() != 0) { return -1; } @@ -882,7 +882,7 @@ int HttpClient::on_upgrade_read(const uint8_t *data, size_t len) { on_readfn = &HttpClient::on_read; on_writefn = &HttpClient::on_write; - rv = on_connect(); + rv = connection_made(); if (rv != 0) { return rv; } @@ -900,7 +900,7 @@ int HttpClient::on_upgrade_read(const uint8_t *data, size_t len) { int HttpClient::do_read() { return readfn(*this); } int HttpClient::do_write() { return writefn(*this); } -int HttpClient::on_connect() { +int HttpClient::connection_made() { int rv; if (!need_upgrade()) { @@ -959,7 +959,7 @@ int HttpClient::on_connect() { } if (stream_user_data) { stream_user_data->stream_id = 1; - on_request(stream_user_data); + request_done(stream_user_data); } } // Send connection header here @@ -1120,7 +1120,7 @@ int HttpClient::tls_handshake() { readfn = &HttpClient::read_tls; writefn = &HttpClient::write_tls; - if (on_connect() != 0) { + if (connection_made() != 0) { return -1; } @@ -1270,7 +1270,7 @@ void HttpClient::record_connect_end_time() { timing.connect_end_time = get_time(); } -void HttpClient::on_request(Request *req) { +void HttpClient::request_done(Request *req) { if (req->pri == 0 && req->dep) { assert(req->dep->deps.empty()); @@ -1664,7 +1664,7 @@ int on_begin_headers_callback(nghttp2_session *session, nghttp2_session_set_stream_user_data(session, stream_id, req.get()); - client->on_request(req.get()); + client->request_done(req.get()); req->record_request_start_time(); client->reqvec.push_back(std::move(req)); diff --git a/src/nghttp.h b/src/nghttp.h index 7466e099..bb2fc449 100644 --- a/src/nghttp.h +++ b/src/nghttp.h @@ -194,8 +194,6 @@ struct HttpClient { int initiate_connection(); void disconnect(); - void on_connect_fail(); - int noop(); int read_clear(); int write_clear(); @@ -212,8 +210,9 @@ struct HttpClient { int on_read(const uint8_t *data, size_t len); int on_write(); - int on_connect(); - void on_request(Request *req); + int connection_made(); + void connect_fail(); + void request_done(Request *req); void signal_write();