diff options
| author | Arseny Smirnov <arseny30@gmail.com> | 2020-07-21 18:29:39 +0300 |
|---|---|---|
| committer | Arseny Smirnov <arseny30@gmail.com> | 2020-07-21 18:29:39 +0300 |
| commit | 38ef3a75cc74b5adb0cb22a72fc0426e8ffd094f (patch) | |
| tree | f4c9c106986f47c19568f458532def3a22e83328 /benchmark | |
| parent | ceb49d01432fce1627e7b5d5a7594eb2eac946d1 (diff) | |
PollableFd: explicit sync_with_poll
GitOrigin-RevId: 71fa35a594816e84e372ebcfa9d0077a13f26a62
Diffstat (limited to 'benchmark')
| -rw-r--r-- | benchmark/bench_http_server_cheat.cpp | 7 | ||||
| -rw-r--r-- | benchmark/bench_http_server_fast.cpp | 7 |
2 files changed, 7 insertions, 7 deletions
diff --git a/benchmark/bench_http_server_cheat.cpp b/benchmark/bench_http_server_cheat.cpp index 8716ec5cf..9e8639881 100644 --- a/benchmark/bench_http_server_cheat.cpp +++ b/benchmark/bench_http_server_cheat.cpp @@ -61,15 +61,16 @@ class HelloWorld : public Actor { } } Status do_loop() { + sync_with_poll(socket_fd_); TRY_STATUS(read_loop()); TRY_STATUS(write_loop()); - if (can_close(socket_fd_)) { + if (can_close_local(socket_fd_)) { return Status::Error("CLOSE"); } return Status::OK(); } Status write_loop() { - while (can_write(socket_fd_) && write_pos_ < write_buf_.size()) { + while (can_write_local(socket_fd_) && write_pos_ < write_buf_.size()) { TRY_RESULT(written, socket_fd_.write(Slice(write_buf_).substr(write_pos_))); write_pos_ += written; if (write_pos_ == write_buf_.size()) { @@ -80,7 +81,7 @@ class HelloWorld : public Actor { return Status::OK(); } Status read_loop() { - while (can_read(socket_fd_)) { + while (can_read_local(socket_fd_)) { TRY_RESULT(read_size, socket_fd_.read(MutableSlice(read_buf.data(), read_buf.size()))); for (size_t i = 0; i < read_size; i++) { if (read_buf[i] == '\n') { diff --git a/benchmark/bench_http_server_fast.cpp b/benchmark/bench_http_server_fast.cpp index c4353dc17..c180c7856 100644 --- a/benchmark/bench_http_server_fast.cpp +++ b/benchmark/bench_http_server_fast.cpp @@ -55,19 +55,18 @@ class HttpEchoConnection : public Actor { } void loop() override { + sync_with_poll(fd_); auto status = [&] { TRY_STATUS(loop_read()); TRY_STATUS(loop_write()); return Status::OK(); }(); - if (status.is_error() || can_close(fd_)) { + if (status.is_error() || can_close_local(fd_)) { stop(); } } Status loop_read() { - if (can_read(fd_)) { - TRY_STATUS(fd_.flush_read()); - } + TRY_STATUS(fd_.flush_read()); while (true) { TRY_RESULT(need, reader_.read_next(&query_)); if (need == 0) { |
