Skip to content

Commit

Permalink
HttpConnection: write_next_noflush for writes without flushing to socket
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 0b4ffbd7600b1ce466caf8a33897b555a2855211
  • Loading branch information
arseny30 committed Jul 13, 2020
1 parent 15c387e commit fee05df
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion benchmark/bench_http_server_fast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion tdnet/td/net/HttpConnectionBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions tdnet/td/net/HttpConnectionBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fee05df

Please sign in to comment.