From 85bb37ab7cc97f3621fba93fff63d0d2a199963f Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 27 Jan 2016 21:14:07 +0900 Subject: [PATCH] Enable ConstructorInitializerAllOnOneLineOrOnePerLine for better diff --- .clang-format | 2 +- src/HttpServer.cc | 50 ++++++++++++---- src/HttpServer.h | 13 ++++- src/asio_client_session_impl.cc | 17 ++++-- src/asio_server_connection.h | 7 ++- src/asio_server_http2_handler.cc | 10 +++- src/asio_server_http2_impl.cc | 3 +- src/asio_server_response_impl.cc | 7 ++- src/h2load.cc | 72 ++++++++++++++++++------ src/h2load_http1_session.cc | 5 +- src/http2.h | 4 +- src/libevent_util.cc | 18 ++++-- src/memchunk.h | 12 +++- src/nghttp.cc | 60 +++++++++++++++----- src/shrpx.cc | 4 +- src/shrpx_client_handler.cc | 4 +- src/shrpx_config.cc | 7 ++- src/shrpx_connection.cc | 8 ++- src/shrpx_connection_handler.cc | 7 ++- src/shrpx_downstream.cc | 25 +++++--- src/shrpx_downstream.h | 28 ++++++--- src/shrpx_http2_downstream_connection.cc | 7 ++- src/shrpx_http2_session.cc | 16 ++++-- src/shrpx_http2_upstream.cc | 4 +- src/shrpx_http_downstream_connection.cc | 5 +- src/shrpx_https_upstream.cc | 3 +- src/shrpx_memcached_connection.cc | 5 +- src/shrpx_rate_limit.cc | 9 ++- src/shrpx_spdy_upstream.cc | 3 +- src/shrpx_worker.cc | 7 ++- 30 files changed, 318 insertions(+), 104 deletions(-) diff --git a/.clang-format b/.clang-format index 291a26e6..01531684 100644 --- a/.clang-format +++ b/.clang-format @@ -17,7 +17,7 @@ BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: false BinPackParameters: true ColumnLimit: 80 -ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true DerivePointerAlignment: false ExperimentalAutoDetectBinPacking: false IndentCaseLabels: false diff --git a/src/HttpServer.cc b/src/HttpServer.cc index b1e0b0fe..10582c62 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -101,12 +101,24 @@ template void append_nv(Stream *stream, const Array &nva) { } // namespace Config::Config() - : mime_types_file("/etc/mime.types"), stream_read_timeout(1_min), - stream_write_timeout(1_min), data_ptr(nullptr), padding(0), num_worker(1), - max_concurrent_streams(100), header_table_size(-1), port(0), - verbose(false), daemon(false), verify_client(false), no_tls(false), - error_gzip(false), early_response(false), hexdump(false), - echo_upload(false), no_content_length(false) {} + : mime_types_file("/etc/mime.types"), + stream_read_timeout(1_min), + stream_write_timeout(1_min), + data_ptr(nullptr), + padding(0), + num_worker(1), + max_concurrent_streams(100), + header_table_size(-1), + port(0), + verbose(false), + daemon(false), + verify_client(false), + no_tls(false), + error_gzip(false), + early_response(false), + hexdump(false), + echo_upload(false), + no_content_length(false) {} Config::~Config() {} @@ -225,8 +237,13 @@ class Sessions { public: Sessions(HttpServer *sv, struct ev_loop *loop, const Config *config, SSL_CTX *ssl_ctx) - : sv_(sv), loop_(loop), config_(config), ssl_ctx_(ssl_ctx), - callbacks_(nullptr), next_session_id_(1), tstamp_cached_(ev_now(loop)), + : sv_(sv), + loop_(loop), + config_(config), + ssl_ctx_(ssl_ctx), + callbacks_(nullptr), + next_session_id_(1), + tstamp_cached_(ev_now(loop)), cached_date_(util::http_date(tstamp_cached_)) { nghttp2_session_callbacks_new(&callbacks_); @@ -424,8 +441,12 @@ void release_fd_cb(struct ev_loop *loop, ev_timer *w, int revents) { } // namespace Stream::Stream(Http2Handler *handler, int32_t stream_id) - : handler(handler), file_ent(nullptr), body_length(0), body_offset(0), - stream_id(stream_id), echo_upload(false) { + : handler(handler), + file_ent(nullptr), + body_length(0), + body_offset(0), + stream_id(stream_id), + echo_upload(false) { auto config = handler->get_config(); ev_timer_init(&rtimer, stream_timeout_cb, 0., config->stream_read_timeout); ev_timer_init(&wtimer, stream_timeout_cb, 0., config->stream_write_timeout); @@ -496,8 +517,13 @@ void writecb(struct ev_loop *loop, ev_io *w, int revents) { Http2Handler::Http2Handler(Sessions *sessions, int fd, SSL *ssl, int64_t session_id) - : session_id_(session_id), session_(nullptr), sessions_(sessions), - ssl_(ssl), data_pending_(nullptr), data_pendinglen_(0), fd_(fd) { + : session_id_(session_id), + session_(nullptr), + sessions_(sessions), + ssl_(ssl), + data_pending_(nullptr), + data_pendinglen_(0), + fd_(fd) { ev_timer_init(&settings_timerev_, settings_timeout_cb, 10., 0.); ev_io_init(&wev_, writecb, fd, EV_WRITE); ev_io_init(&rev_, readcb, fd, EV_READ); diff --git a/src/HttpServer.h b/src/HttpServer.h index 3e889711..ff2b844f 100644 --- a/src/HttpServer.h +++ b/src/HttpServer.h @@ -87,9 +87,16 @@ struct FileEntry { FileEntry(std::string path, int64_t length, int64_t mtime, int fd, const std::string *content_type, ev_tstamp last_valid, bool stale = false) - : path(std::move(path)), length(length), mtime(mtime), - last_valid(last_valid), content_type(content_type), dlnext(nullptr), - dlprev(nullptr), fd(fd), usecount(1), stale(stale) {} + : path(std::move(path)), + length(length), + mtime(mtime), + last_valid(last_valid), + content_type(content_type), + dlnext(nullptr), + dlprev(nullptr), + fd(fd), + usecount(1), + stale(stale) {} std::string path; std::multimap>::iterator it; int64_t length; diff --git a/src/asio_client_session_impl.cc b/src/asio_client_session_impl.cc index a4cce25a..fa275f8e 100644 --- a/src/asio_client_session_impl.cc +++ b/src/asio_client_session_impl.cc @@ -39,11 +39,18 @@ namespace asio_http2 { namespace client { session_impl::session_impl(boost::asio::io_service &io_service) - : wblen_(0), io_service_(io_service), resolver_(io_service), - deadline_(io_service), connect_timeout_(boost::posix_time::seconds(60)), - read_timeout_(boost::posix_time::seconds(60)), session_(nullptr), - data_pending_(nullptr), data_pendinglen_(0), writing_(false), - inside_callback_(false), stopped_(false) {} + : wblen_(0), + io_service_(io_service), + resolver_(io_service), + deadline_(io_service), + connect_timeout_(boost::posix_time::seconds(60)), + read_timeout_(boost::posix_time::seconds(60)), + session_(nullptr), + data_pending_(nullptr), + data_pendinglen_(0), + writing_(false), + inside_callback_(false), + stopped_(false) {} session_impl::~session_impl() { // finish up all active stream diff --git a/src/asio_server_connection.h b/src/asio_server_connection.h index 4cab44b4..4498497d 100644 --- a/src/asio_server_connection.h +++ b/src/asio_server_connection.h @@ -69,10 +69,13 @@ public: const boost::posix_time::time_duration &tls_handshake_timeout, const boost::posix_time::time_duration &read_timeout, SocketArgs &&... args) - : socket_(std::forward(args)...), mux_(mux), + : socket_(std::forward(args)...), + mux_(mux), deadline_(socket_.get_io_service()), tls_handshake_timeout_(tls_handshake_timeout), - read_timeout_(read_timeout), writing_(false), stopped_(false) {} + read_timeout_(read_timeout), + writing_(false), + stopped_(false) {} /// Start the first asynchronous operation for the connection. void start() { diff --git a/src/asio_server_http2_handler.cc b/src/asio_server_http2_handler.cc index 48e0bd14..b08f2021 100644 --- a/src/asio_server_http2_handler.cc +++ b/src/asio_server_http2_handler.cc @@ -230,8 +230,14 @@ int on_frame_not_send_callback(nghttp2_session *session, http2_handler::http2_handler(boost::asio::io_service &io_service, boost::asio::ip::tcp::endpoint ep, connection_write writefun, serve_mux &mux) - : writefun_(writefun), mux_(mux), io_service_(io_service), remote_ep_(ep), - session_(nullptr), buf_(nullptr), buflen_(0), inside_callback_(false), + : writefun_(writefun), + mux_(mux), + io_service_(io_service), + remote_ep_(ep), + session_(nullptr), + buf_(nullptr), + buflen_(0), + inside_callback_(false), tstamp_cached_(time(nullptr)), formatted_date_(util::http_date(tstamp_cached_)) {} diff --git a/src/asio_server_http2_impl.cc b/src/asio_server_http2_impl.cc index 6a047f66..da138b7a 100644 --- a/src/asio_server_http2_impl.cc +++ b/src/asio_server_http2_impl.cc @@ -38,7 +38,8 @@ namespace asio_http2 { namespace server { http2_impl::http2_impl() - : num_threads_(1), backlog_(-1), + : num_threads_(1), + backlog_(-1), tls_handshake_timeout_(boost::posix_time::seconds(60)), read_timeout_(boost::posix_time::seconds(60)) {} diff --git a/src/asio_server_response_impl.cc b/src/asio_server_response_impl.cc index 1cdbc591..3216ca02 100644 --- a/src/asio_server_response_impl.cc +++ b/src/asio_server_response_impl.cc @@ -36,8 +36,11 @@ namespace asio_http2 { namespace server { response_impl::response_impl() - : strm_(nullptr), generator_cb_(deferred_generator()), status_code_(200), - state_(response_state::INITIAL), pushed_(false), + : strm_(nullptr), + generator_cb_(deferred_generator()), + status_code_(200), + state_(response_state::INITIAL), + pushed_(false), push_promise_sent_(false) {} unsigned int response_impl::status_code() const { return status_code_; } diff --git a/src/h2load.cc b/src/h2load.cc index d2aad6bf..aeedbe7f 100644 --- a/src/h2load.cc +++ b/src/h2load.cc @@ -79,11 +79,24 @@ bool recorded(const std::chrono::steady_clock::time_point &t) { } // namespace Config::Config() - : data_length(-1), addrs(nullptr), nreqs(1), nclients(1), nthreads(1), - max_concurrent_streams(-1), window_bits(30), connection_window_bits(30), - rate(0), rate_period(1.0), conn_active_timeout(0.), - conn_inactivity_timeout(0.), no_tls_proto(PROTO_HTTP2), data_fd(-1), - port(0), default_port(0), verbose(false), timing_script(false) {} + : data_length(-1), + addrs(nullptr), + nreqs(1), + nclients(1), + nthreads(1), + max_concurrent_streams(-1), + window_bits(30), + connection_window_bits(30), + rate(0), + rate_period(1.0), + conn_active_timeout(0.), + conn_inactivity_timeout(0.), + no_tls_proto(PROTO_HTTP2), + data_fd(-1), + port(0), + default_port(0), + verbose(false), + timing_script(false) {} Config::~Config() { if (base_uri_unix) { @@ -106,9 +119,18 @@ constexpr size_t MAX_SAMPLES = 1000000; } // namespace Stats::Stats(size_t req_todo, size_t nclients) - : req_todo(req_todo), req_started(0), req_done(0), req_success(0), - req_status_success(0), req_failed(0), req_error(0), req_timedout(0), - bytes_total(0), bytes_head(0), bytes_head_decomp(0), bytes_body(0), + : req_todo(req_todo), + req_started(0), + req_done(0), + req_success(0), + req_status_success(0), + req_failed(0), + req_error(0), + req_timedout(0), + bytes_total(0), + bytes_head(0), + bytes_head_decomp(0), + bytes_body(0), status() {} Stream::Stream() : req_stat{}, status_success(-1) {} @@ -290,9 +312,18 @@ void client_request_timeout_cb(struct ev_loop *loop, ev_timer *w, int revents) { } // namespace Client::Client(uint32_t id, Worker *worker, size_t req_todo) - : cstat{}, worker(worker), ssl(nullptr), next_addr(config.addrs), - current_addr(nullptr), reqidx(0), state(CLIENT_IDLE), req_todo(req_todo), - req_started(0), req_done(0), id(id), fd(-1), + : cstat{}, + worker(worker), + ssl(nullptr), + next_addr(config.addrs), + current_addr(nullptr), + reqidx(0), + state(CLIENT_IDLE), + req_todo(req_todo), + req_started(0), + req_done(0), + id(id), + fd(-1), new_connection_requested(false) { ev_io_init(&wev, writecb, 0, EV_WRITE); ev_io_init(&rev, readcb, 0, EV_READ); @@ -1094,11 +1125,20 @@ void Client::try_new_connection() { new_connection_requested = true; } Worker::Worker(uint32_t id, SSL_CTX *ssl_ctx, size_t req_todo, size_t nclients, size_t rate, size_t max_samples, Config *config) - : stats(req_todo, nclients), loop(ev_loop_new(0)), ssl_ctx(ssl_ctx), - config(config), id(id), tls_info_report_done(false), - app_info_report_done(false), nconns_made(0), nclients(nclients), - nreqs_per_client(req_todo / nclients), nreqs_rem(req_todo % nclients), - rate(rate), max_samples(max_samples), next_client_id(0) { + : stats(req_todo, nclients), + loop(ev_loop_new(0)), + ssl_ctx(ssl_ctx), + config(config), + id(id), + tls_info_report_done(false), + app_info_report_done(false), + nconns_made(0), + nclients(nclients), + nreqs_per_client(req_todo / nclients), + nreqs_rem(req_todo % nclients), + rate(rate), + max_samples(max_samples), + next_client_id(0) { if (!config->is_rate_mode()) { progress_interval = std::max(static_cast(1), req_todo / 10); } else { diff --git a/src/h2load_http1_session.cc b/src/h2load_http1_session.cc index a295c625..4f4b6c59 100644 --- a/src/h2load_http1_session.cc +++ b/src/h2load_http1_session.cc @@ -41,7 +41,10 @@ using namespace nghttp2; namespace h2load { Http1Session::Http1Session(Client *client) - : stream_req_counter_(1), stream_resp_counter_(1), client_(client), htp_(), + : stream_req_counter_(1), + stream_resp_counter_(1), + client_(client), + htp_(), complete_(false) { http_parser_init(&htp_, HTTP_RESPONSE); htp_.data = this; diff --git a/src/http2.h b/src/http2.h index 80be3fc9..8eaeff56 100644 --- a/src/http2.h +++ b/src/http2.h @@ -45,7 +45,9 @@ namespace nghttp2 { struct Header { Header(std::string name, std::string value, bool no_index = false, int16_t token = -1) - : name(std::move(name)), value(std::move(value)), token(token), + : name(std::move(name)), + value(std::move(value)), + token(token), no_index(no_index) {} Header() : token(-1), no_index(false) {} diff --git a/src/libevent_util.cc b/src/libevent_util.cc index 23edea51..3b60b6d9 100644 --- a/src/libevent_util.cc +++ b/src/libevent_util.cc @@ -32,13 +32,23 @@ namespace nghttp2 { namespace util { EvbufferBuffer::EvbufferBuffer() - : evbuffer_(nullptr), bucket_(nullptr), buf_(nullptr), bufmax_(0), - buflen_(0), limit_(0), writelen_(0) {} + : evbuffer_(nullptr), + bucket_(nullptr), + buf_(nullptr), + bufmax_(0), + buflen_(0), + limit_(0), + writelen_(0) {} EvbufferBuffer::EvbufferBuffer(evbuffer *evbuffer, uint8_t *buf, size_t bufmax, ssize_t limit) - : evbuffer_(evbuffer), bucket_(limit == -1 ? nullptr : evbuffer_new()), - buf_(buf), bufmax_(bufmax), buflen_(0), limit_(limit), writelen_(0) {} + : evbuffer_(evbuffer), + bucket_(limit == -1 ? nullptr : evbuffer_new()), + buf_(buf), + bufmax_(bufmax), + buflen_(0), + limit_(limit), + writelen_(0) {} void EvbufferBuffer::reset(evbuffer *evbuffer, uint8_t *buf, size_t bufmax, ssize_t limit) { diff --git a/src/memchunk.h b/src/memchunk.h index 81e4ef11..4cfd3b12 100644 --- a/src/memchunk.h +++ b/src/memchunk.h @@ -51,7 +51,9 @@ namespace nghttp2 { template struct Memchunk { Memchunk(std::unique_ptr next_chunk) - : pos(std::begin(buf)), last(pos), knext(std::move(next_chunk)), + : pos(std::begin(buf)), + last(pos), + knext(std::move(next_chunk)), next(nullptr) {} size_t len() const { return last - pos; } size_t left() const { return std::end(buf) - last; } @@ -290,8 +292,12 @@ template struct Memchunks { // Wrapper around Memchunks to offer "peeking" functionality. template struct PeekMemchunks { PeekMemchunks(Pool *pool) - : memchunks(pool), cur(nullptr), cur_pos(nullptr), cur_last(nullptr), - len(0), peeking(true) {} + : memchunks(pool), + cur(nullptr), + cur_pos(nullptr), + cur_last(nullptr), + len(0), + peeking(true) {} PeekMemchunks(const PeekMemchunks &) = delete; PeekMemchunks(PeekMemchunks &&other) noexcept : memchunks(std::move(other.memchunks)), diff --git a/src/nghttp.cc b/src/nghttp.cc index df33e12d..c7dd4d48 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -94,13 +94,26 @@ constexpr auto anchors = std::array{{ Config::Config() : header_table_size(-1), - min_header_table_size(std::numeric_limits::max()), padding(0), - max_concurrent_streams(100), peer_max_concurrent_streams(100), - weight(NGHTTP2_DEFAULT_WEIGHT), multiply(1), timeout(0.), window_bits(-1), - connection_window_bits(-1), verbose(0), null_out(false), - remote_name(false), get_assets(false), stat(false), upgrade(false), - continuation(false), no_content_length(false), no_dep(false), - hexdump(false), no_push(false) { + min_header_table_size(std::numeric_limits::max()), + padding(0), + max_concurrent_streams(100), + peer_max_concurrent_streams(100), + weight(NGHTTP2_DEFAULT_WEIGHT), + multiply(1), + timeout(0.), + window_bits(-1), + connection_window_bits(-1), + verbose(0), + null_out(false), + remote_name(false), + get_assets(false), + stat(false), + upgrade(false), + continuation(false), + no_content_length(false), + no_dep(false), + hexdump(false), + no_push(false) { nghttp2_option_new(&http2_option); nghttp2_option_set_peer_max_concurrent_streams(http2_option, peer_max_concurrent_streams); @@ -133,9 +146,18 @@ std::string strip_fragment(const char *raw_uri) { Request::Request(const std::string &uri, const http_parser_url &u, const nghttp2_data_provider *data_prd, int64_t data_length, const nghttp2_priority_spec &pri_spec, int level) - : uri(uri), u(u), pri_spec(pri_spec), data_length(data_length), - data_offset(0), response_len(0), inflater(nullptr), html_parser(nullptr), - data_prd(data_prd), stream_id(-1), status(0), level(level), + : uri(uri), + u(u), + pri_spec(pri_spec), + data_length(data_length), + data_offset(0), + response_len(0), + inflater(nullptr), + html_parser(nullptr), + data_prd(data_prd), + stream_id(-1), + status(0), + level(level), expect_final_response(false) { http2::init_hdidx(res_hdidx); http2::init_hdidx(req_hdidx); @@ -467,10 +489,20 @@ void settings_timeout_cb(struct ev_loop *loop, ev_timer *w, int revents) { HttpClient::HttpClient(const nghttp2_session_callbacks *callbacks, struct ev_loop *loop, SSL_CTX *ssl_ctx) - : session(nullptr), callbacks(callbacks), loop(loop), ssl_ctx(ssl_ctx), - ssl(nullptr), addrs(nullptr), next_addr(nullptr), cur_addr(nullptr), - complete(0), success(0), settings_payloadlen(0), state(ClientState::IDLE), - upgrade_response_status_code(0), fd(-1), + : session(nullptr), + callbacks(callbacks), + loop(loop), + ssl_ctx(ssl_ctx), + ssl(nullptr), + addrs(nullptr), + next_addr(nullptr), + cur_addr(nullptr), + complete(0), + success(0), + settings_payloadlen(0), + state(ClientState::IDLE), + upgrade_response_status_code(0), + fd(-1), upgrade_response_complete(false) { ev_io_init(&wev, writecb, 0, EV_WRITE); ev_io_init(&rev, readcb, 0, EV_READ); diff --git a/src/shrpx.cc b/src/shrpx.cc index 494fb01d..cc194774 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -123,7 +123,9 @@ namespace shrpx { struct SignalServer { SignalServer() - : ipc_fd{{-1, -1}}, server_fd(-1), server_fd6(-1), + : ipc_fd{{-1, -1}}, + server_fd(-1), + server_fd6(-1), worker_process_pid(-1) {} ~SignalServer() { if (server_fd6 != -1) { diff --git a/src/shrpx_client_handler.cc b/src/shrpx_client_handler.cc index 01e2955d..55e1f791 100644 --- a/src/shrpx_client_handler.cc +++ b/src/shrpx_client_handler.cc @@ -390,7 +390,9 @@ ClientHandler::ClientHandler(Worker *worker, int fd, SSL *ssl, ? make_unique>( get_config()->conn.downstream.addr_groups.size(), -1) : nullptr), - ipaddr_(ipaddr), port_(port), worker_(worker), + ipaddr_(ipaddr), + port_(port), + worker_(worker), left_connhd_len_(NGHTTP2_CLIENT_MAGIC_LEN), should_close_after_write_(false) { diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index 9401013b..d71e1caa 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -81,8 +81,11 @@ TicketKeys::~TicketKeys() { } DownstreamAddr::DownstreamAddr(const DownstreamAddr &other) - : addr(other.addr), host(other.host), hostport(other.hostport), - port(other.port), host_unix(other.host_unix) {} + : addr(other.addr), + host(other.host), + hostport(other.hostport), + port(other.port), + host_unix(other.host_unix) {} DownstreamAddr &DownstreamAddr::operator=(const DownstreamAddr &other) { if (this == &other) { diff --git a/src/shrpx_connection.cc b/src/shrpx_connection.cc index 5d27d110..9a1b6aca 100644 --- a/src/shrpx_connection.cc +++ b/src/shrpx_connection.cc @@ -51,8 +51,12 @@ Connection::Connection(struct ev_loop *loop, int fd, SSL *ssl, : tls{DefaultMemchunks(mcpool), DefaultPeekMemchunks(mcpool)}, wlimit(loop, &wev, write_limit.rate, write_limit.burst), rlimit(loop, &rev, read_limit.rate, read_limit.burst, this), - writecb(writecb), readcb(readcb), timeoutcb(timeoutcb), loop(loop), - data(data), fd(fd), + writecb(writecb), + readcb(readcb), + timeoutcb(timeoutcb), + loop(loop), + data(data), + fd(fd), tls_dyn_rec_warmup_threshold(tls_dyn_rec_warmup_threshold), tls_dyn_rec_idle_timeout(tls_dyn_rec_idle_timeout) { diff --git a/src/shrpx_connection_handler.cc b/src/shrpx_connection_handler.cc index 1e6504b0..3b7c049e 100644 --- a/src/shrpx_connection_handler.cc +++ b/src/shrpx_connection_handler.cc @@ -107,9 +107,12 @@ std::random_device rd; } // namespace ConnectionHandler::ConnectionHandler(struct ev_loop *loop) - : gen_(rd()), single_worker_(nullptr), loop_(loop), + : gen_(rd()), + single_worker_(nullptr), + loop_(loop), tls_ticket_key_memcached_get_retry_count_(0), - tls_ticket_key_memcached_fail_count_(0), worker_round_robin_cnt_(0), + tls_ticket_key_memcached_fail_count_(0), + worker_round_robin_cnt_(0), graceful_shutdown_(false) { ev_timer_init(&disable_acceptor_timer_, acceptor_disable_cb, 0., 0.); disable_acceptor_timer_.data = this; diff --git a/src/shrpx_downstream.cc b/src/shrpx_downstream.cc index 0880b0d5..8f8165b7 100644 --- a/src/shrpx_downstream.cc +++ b/src/shrpx_downstream.cc @@ -113,15 +113,26 @@ void downstream_wtimeoutcb(struct ev_loop *loop, ev_timer *w, int revents) { // upstream could be nullptr for unittests Downstream::Downstream(Upstream *upstream, MemchunkPool *mcpool, int32_t stream_id) - : dlnext(nullptr), dlprev(nullptr), response_sent_body_length(0), + : dlnext(nullptr), + dlprev(nullptr), + response_sent_body_length(0), request_start_time_(std::chrono::high_resolution_clock::now()), - request_buf_(mcpool), response_buf_(mcpool), upstream_(upstream), - blocked_link_(nullptr), num_retry_(0), stream_id_(stream_id), - assoc_stream_id_(-1), downstream_stream_id_(-1), + request_buf_(mcpool), + response_buf_(mcpool), + upstream_(upstream), + blocked_link_(nullptr), + num_retry_(0), + stream_id_(stream_id), + assoc_stream_id_(-1), + downstream_stream_id_(-1), response_rst_stream_error_code_(NGHTTP2_NO_ERROR), - request_state_(INITIAL), response_state_(INITIAL), - dispatch_state_(DISPATCH_NONE), upgraded_(false), chunked_request_(false), - chunked_response_(false), expect_final_response_(false), + request_state_(INITIAL), + response_state_(INITIAL), + dispatch_state_(DISPATCH_NONE), + upgraded_(false), + chunked_request_(false), + chunked_response_(false), + expect_final_response_(false), request_pending_(false) { auto &timeoutconf = get_config()->http2.timeout; diff --git a/src/shrpx_downstream.h b/src/shrpx_downstream.h index c5fecae9..a1f32760 100644 --- a/src/shrpx_downstream.h +++ b/src/shrpx_downstream.h @@ -52,7 +52,9 @@ struct BlockedLink; class FieldStore { public: FieldStore(size_t headers_initial_capacity) - : content_length(-1), buffer_size_(0), header_key_prev_(false), + : content_length(-1), + buffer_size_(0), + header_key_prev_(false), trailer_key_prev_(false) { http2::init_hdidx(hdidx_); headers_.reserve(headers_initial_capacity); @@ -124,10 +126,17 @@ private: struct Request { Request() - : fs(16), recv_body_length(0), unconsumed_body_length(0), method(-1), - http_major(1), http_minor(1), upgrade_request(false), - http2_upgrade_seen(false), connection_close(false), - http2_expect_body(false), no_authority(false) {} + : fs(16), + recv_body_length(0), + unconsumed_body_length(0), + method(-1), + http_major(1), + http_minor(1), + upgrade_request(false), + http2_upgrade_seen(false), + connection_close(false), + http2_expect_body(false), + no_authority(false) {} void consume(size_t len) { assert(unconsumed_body_length >= len); @@ -173,8 +182,13 @@ struct Request { struct Response { Response() - : fs(32), recv_body_length(0), unconsumed_body_length(0), http_status(0), - http_major(1), http_minor(1), connection_close(false) {} + : fs(32), + recv_body_length(0), + unconsumed_body_length(0), + http_status(0), + http_major(1), + http_minor(1), + connection_close(false) {} void consume(size_t len) { assert(unconsumed_body_length >= len); diff --git a/src/shrpx_http2_downstream_connection.cc b/src/shrpx_http2_downstream_connection.cc index 55e7980c..3ca718c1 100644 --- a/src/shrpx_http2_downstream_connection.cc +++ b/src/shrpx_http2_downstream_connection.cc @@ -46,8 +46,11 @@ namespace shrpx { Http2DownstreamConnection::Http2DownstreamConnection( DownstreamConnectionPool *dconn_pool, Http2Session *http2session) - : DownstreamConnection(dconn_pool), dlnext(nullptr), dlprev(nullptr), - http2session_(http2session), sd_(nullptr) {} + : DownstreamConnection(dconn_pool), + dlnext(nullptr), + dlprev(nullptr), + http2session_(http2session), + sd_(nullptr) {} Http2DownstreamConnection::~Http2DownstreamConnection() { if (LOG_ENABLED(INFO)) { diff --git a/src/shrpx_http2_session.cc b/src/shrpx_http2_session.cc index 29cbc39f..a49c799f 100644 --- a/src/shrpx_http2_session.cc +++ b/src/shrpx_http2_session.cc @@ -150,10 +150,18 @@ Http2Session::Http2Session(struct ev_loop *loop, SSL_CTX *ssl_ctx, get_config()->conn.downstream.timeout.read, {}, {}, writecb, readcb, timeoutcb, this, get_config()->tls.dyn_rec.warmup_threshold, get_config()->tls.dyn_rec.idle_timeout), - worker_(worker), connect_blocker_(connect_blocker), ssl_ctx_(ssl_ctx), - session_(nullptr), data_pending_(nullptr), data_pendinglen_(0), - addr_idx_(0), group_(group), index_(idx), state_(DISCONNECTED), - connection_check_state_(CONNECTION_CHECK_NONE), flow_control_(false) { + worker_(worker), + connect_blocker_(connect_blocker), + ssl_ctx_(ssl_ctx), + session_(nullptr), + data_pending_(nullptr), + data_pendinglen_(0), + addr_idx_(0), + group_(group), + index_(idx), + state_(DISCONNECTED), + connection_check_state_(CONNECTION_CHECK_NONE), + flow_control_(false) { read_ = write_ = &Http2Session::noop; on_read_ = on_write_ = &Http2Session::noop; diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index 2c525a74..363769cf 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -826,7 +826,9 @@ Http2Upstream::Http2Upstream(ClientHandler *handler) ? get_config()->conn.downstream.connections_per_frontend : 0, !get_config()->http2_proxy), - handler_(handler), session_(nullptr), shutdown_handled_(false) { + handler_(handler), + session_(nullptr), + shutdown_handled_(false) { int rv; diff --git a/src/shrpx_http_downstream_connection.cc b/src/shrpx_http_downstream_connection.cc index 7c5a81a5..982eedd7 100644 --- a/src/shrpx_http_downstream_connection.cc +++ b/src/shrpx_http_downstream_connection.cc @@ -118,7 +118,10 @@ HttpDownstreamConnection::HttpDownstreamConnection( get_config()->conn.downstream.timeout.read, {}, {}, connectcb, readcb, timeoutcb, this, get_config()->tls.dyn_rec.warmup_threshold, get_config()->tls.dyn_rec.idle_timeout), - ioctrl_(&conn_.rlimit), response_htp_{0}, group_(group), addr_idx_(0), + ioctrl_(&conn_.rlimit), + response_htp_{0}, + group_(group), + addr_idx_(0), connected_(false) {} HttpDownstreamConnection::~HttpDownstreamConnection() {} diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index e91384d4..0c288cab 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -49,7 +49,8 @@ using namespace nghttp2; namespace shrpx { HttpsUpstream::HttpsUpstream(ClientHandler *handler) - : handler_(handler), current_header_length_(0), + : handler_(handler), + current_header_length_(0), ioctrl_(handler->get_rlimit()) { http_parser_init(&htp_, HTTP_REQUEST); htp_.data = this; diff --git a/src/shrpx_memcached_connection.cc b/src/shrpx_memcached_connection.cc index 8bb01aab..8c4d1cc2 100644 --- a/src/shrpx_memcached_connection.cc +++ b/src/shrpx_memcached_connection.cc @@ -94,7 +94,10 @@ MemcachedConnection::MemcachedConnection(const Address *addr, struct ev_loop *loop) : conn_(loop, -1, nullptr, nullptr, write_timeout, read_timeout, {}, {}, connectcb, readcb, timeoutcb, this, 0, 0.), - parse_state_{}, addr_(addr), sendsum_(0), connected_(false) {} + parse_state_{}, + addr_(addr), + sendsum_(0), + connected_(false) {} MemcachedConnection::~MemcachedConnection() { disconnect(); } diff --git a/src/shrpx_rate_limit.cc b/src/shrpx_rate_limit.cc index e184921b..182e10a6 100644 --- a/src/shrpx_rate_limit.cc +++ b/src/shrpx_rate_limit.cc @@ -39,8 +39,13 @@ void regencb(struct ev_loop *loop, ev_timer *w, int revents) { RateLimit::RateLimit(struct ev_loop *loop, ev_io *w, size_t rate, size_t burst, Connection *conn) - : w_(w), loop_(loop), conn_(conn), rate_(rate), burst_(burst), - avail_(burst), startw_req_(false) { + : w_(w), + loop_(loop), + conn_(conn), + rate_(rate), + burst_(burst), + avail_(burst), + startw_req_(false) { ev_timer_init(&t_, regencb, 0., 1.); t_.data = this; if (rate_ > 0) { diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index d9e8df4a..0b3388a0 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -504,7 +504,8 @@ SpdyUpstream::SpdyUpstream(uint16_t version, ClientHandler *handler) ? get_config()->conn.downstream.connections_per_frontend : 0, !get_config()->http2_proxy), - handler_(handler), session_(nullptr) { + handler_(handler), + session_(nullptr) { spdylay_session_callbacks callbacks{}; callbacks.send_callback = send_callback; callbacks.recv_callback = recv_callback; diff --git a/src/shrpx_worker.cc b/src/shrpx_worker.cc index d6282d37..ae64c3e0 100644 --- a/src/shrpx_worker.cc +++ b/src/shrpx_worker.cc @@ -72,8 +72,11 @@ Worker::Worker(struct ev_loop *loop, SSL_CTX *sv_ssl_ctx, SSL_CTX *cl_ssl_ctx, : randgen_(rd()), dconn_pool_(get_config()->conn.downstream.addr_groups.size()), worker_stat_(get_config()->conn.downstream.addr_groups.size()), - dgrps_(get_config()->conn.downstream.addr_groups.size()), loop_(loop), - sv_ssl_ctx_(sv_ssl_ctx), cl_ssl_ctx_(cl_ssl_ctx), cert_tree_(cert_tree), + dgrps_(get_config()->conn.downstream.addr_groups.size()), + loop_(loop), + sv_ssl_ctx_(sv_ssl_ctx), + cl_ssl_ctx_(cl_ssl_ctx), + cert_tree_(cert_tree), ticket_keys_(ticket_keys), connect_blocker_(make_unique(loop_)), graceful_shutdown_(false) {