diff options
| author | Arseny Smirnov <arseny30@gmail.com> | 2020-07-13 11:55:43 +0300 |
|---|---|---|
| committer | Arseny Smirnov <arseny30@gmail.com> | 2020-07-13 11:55:43 +0300 |
| commit | fee05df2cc4ac4ce9ddf6237de88f3e182d519d7 (patch) | |
| tree | 0e5065e989fa930afd595914b53a0f1672ebeabd | |
| parent | 15c387eff0490f4ca1f15a47f190d6e7965845ea (diff) | |
HttpConnection: write_next_noflush for writes without flushing to socket
GitOrigin-RevId: 0b4ffbd7600b1ce466caf8a33897b555a2855211
| -rw-r--r-- | benchmark/bench_http_server_fast.cpp | 6 | ||||
| -rw-r--r-- | tdnet/td/net/HttpConnectionBase.cpp | 5 | ||||
| -rw-r--r-- | tdnet/td/net/HttpConnectionBase.h | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/benchmark/bench_http_server_fast.cpp b/benchmark/bench_http_server_fast.cpp index 0d012f112..c4353dc17 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 9c673b323..5de245bd2 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 296d342ed..bf8bf7e78 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); |
