diff --git a/benchmark/bench_http_server_fast.cpp b/benchmark/bench_http_server_fast.cpp index 0d012f1127bf..c4353dc1754e 100644 --- a/benchmark/bench_http_server_fast.cpp +++ b/benchmark/bench_http_server_fast.cpp @@ -34,6 +34,10 @@ class HttpEchoConnection : public Actor { Scheduler::subscribe(fd_.get_poll_info().extract_pollable_fd(this)); reader_.init(&fd_.input_buffer(), 1024 * 1024, 0); } + void tear_down() override { + Scheduler::unsubscribe_before_close(fd_.get_poll_info().get_pollable_fd_ref()); + fd_.close(); + } void handle_query() { query_ = HttpQuery(); @@ -80,7 +84,7 @@ class HttpEchoConnection : public Actor { } }; -const int N = 4; +const int N = 8; class Server : public TcpListener::Callback { public: void start_up() override { diff --git a/tdnet/td/net/HttpConnectionBase.cpp b/tdnet/td/net/HttpConnectionBase.cpp index 9c673b32356c..5de245bd2680 100644 --- a/tdnet/td/net/HttpConnectionBase.cpp +++ b/tdnet/td/net/HttpConnectionBase.cpp @@ -55,9 +55,12 @@ void HttpConnectionBase::tear_down() { fd_.close(); } -void HttpConnectionBase::write_next(BufferSlice buffer) { +void HttpConnectionBase::write_next_noflush(BufferSlice buffer) { CHECK(state_ == State::Write); write_buffer_.append(std::move(buffer)); +} +void HttpConnectionBase::write_next(BufferSlice buffer) { + write_next_noflush(std::move(buffer)); loop(); } diff --git a/tdnet/td/net/HttpConnectionBase.h b/tdnet/td/net/HttpConnectionBase.h index 296d342eda9c..bf8bf7e78ab8 100644 --- a/tdnet/td/net/HttpConnectionBase.h +++ b/tdnet/td/net/HttpConnectionBase.h @@ -24,6 +24,7 @@ namespace detail { class HttpConnectionBase : public Actor { public: + void write_next_noflush(BufferSlice buffer); void write_next(BufferSlice buffer); void write_ok(); void write_error(Status error);