diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 78292e9c..655ddf83 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -259,8 +259,8 @@ public: void accept_connection(int fd) { int val = 1; - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, - reinterpret_cast(&val), sizeof(val)); + (void)setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, + reinterpret_cast(&val), sizeof(val)); SSL *ssl = nullptr; if(ssl_ctx_) { ssl = ssl_session_new(fd); @@ -1309,7 +1309,7 @@ int hd_on_frame_send_callback auto promised_stream = hd->get_stream(promised_stream_id); auto stream = hd->get_stream(frame->hd.stream_id); - if(!promised_stream) { + if(!stream || !promised_stream) { return 0; } @@ -1550,7 +1550,9 @@ int start_listen(event_base *evbase, Sessions *sessions, const Config *config) hints.ai_flags |= AI_ADDRCONFIG; #endif // AI_ADDRCONFIG - auto listen_handler = new ListenEventHandler(sessions, config); + auto listen_handler_store = + util::make_unique(sessions, config); + auto listen_handler = listen_handler_store.get(); addrinfo *res, *rp; r = getaddrinfo(nullptr, service, &hints, &res); @@ -1585,6 +1587,8 @@ int start_listen(event_base *evbase, Sessions *sessions, const Config *config) LEV_OPT_REUSEABLE | LEV_OPT_CLOSE_ON_FREE, -1, fd); evconnlistener_set_error_cb(evlistener, evlistener_errorcb); + listen_handler_store.release(); + if(config->verbose) { std::cout << (rp->ai_family == AF_INET ? "IPv4" : "IPv6") << ": listen on port " diff --git a/src/deflatehd.cc b/src/deflatehd.cc index 03a4deb0..af5842ff 100644 --- a/src/deflatehd.cc +++ b/src/deflatehd.cc @@ -86,12 +86,13 @@ static void output_to_json(nghttp2_hd_deflater *deflater, auto len = nghttp2_bufs_len(bufs); auto hex = std::vector(len * 2); auto obj = json_object(); + auto comp_ratio = inputlen == 0 ? 0.0 : (double)len / inputlen * 100; json_object_set_new(obj, "seq", json_integer(seq)); json_object_set_new(obj, "input_length", json_integer(inputlen)); json_object_set_new(obj, "output_length", json_integer(len)); json_object_set_new(obj, "percentage_of_original_size", - json_real((double)len / inputlen * 100)); + json_real(comp_ratio)); auto hexp = hex.data(); for(auto ci = bufs->head; ci; ci = ci->next) { @@ -462,7 +463,10 @@ int main(int argc, char **argv) } else { perform(); } + + auto comp_ratio = input_sum == 0 ? 0.0 : (double)output_sum / input_sum; + fprintf(stderr, "Overall: input=%zu output=%zu ratio=%.02f\n", - input_sum, output_sum, (double)output_sum / input_sum); + input_sum, output_sum, comp_ratio); return 0; } diff --git a/src/h2load.cc b/src/h2load.cc index a463c5f2..33d1e272 100644 --- a/src/h2load.cc +++ b/src/h2load.cc @@ -428,8 +428,8 @@ void eventcb(bufferevent *bev, short events, void *ptr) } int fd = bufferevent_getfd(bev); int val = 1; - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, - reinterpret_cast(&val), sizeof(val)); + (void)setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, + reinterpret_cast(&val), sizeof(val)); client->state = CLIENT_CONNECTED; client->on_connect(); return; diff --git a/src/h2load_http2_session.cc b/src/h2load_http2_session.cc index 1a0db3ca..1b0e0fb8 100644 --- a/src/h2load_http2_session.cc +++ b/src/h2load_http2_session.cc @@ -24,6 +24,8 @@ */ #include "h2load_http2_session.h" +#include + #include "h2load.h" #include "util.h" @@ -111,6 +113,8 @@ int on_stream_close_callback void Http2Session::on_connect() { + int rv; + nghttp2_session_callbacks callbacks = {0}; callbacks.before_frame_send_callback = before_frame_send_callback; callbacks.on_frame_recv_callback = on_frame_recv_callback; @@ -125,8 +129,11 @@ void Http2Session::on_connect() iv[0].value = 0; iv[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; iv[1].value = (1 << client_->worker->config->window_bits) - 1; - nghttp2_submit_settings(session_, NGHTTP2_FLAG_NONE, iv, - sizeof(iv) / sizeof(iv[0])); + + rv = nghttp2_submit_settings(session_, NGHTTP2_FLAG_NONE, iv, + sizeof(iv) / sizeof(iv[0])); + + assert(rv == 0); auto extra_connection_window = (1 << client_->worker->config->connection_window_bits) - 1 diff --git a/src/shrpx.cc b/src/shrpx.cc index 4fb00956..26ec33fe 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -818,7 +818,7 @@ int main(int argc, char **argv) std::vector > cmdcfgs; while(1) { - int flag; + int flag = 0; static option long_options[] = { {"daemon", no_argument, nullptr, 'D'}, {"log-level", required_argument, nullptr, 'L'},