Tidy two spots left from the keep-alive parking review

drain_and_close_socket() checks the size bound before it reads the clock,
which saves a clock read on a drain that stops at 1 MB, and the comment
on PollPoller::fds_ fits on one line. Nothing else changes.
This commit is contained in:
yhirose committed 2026-11-21 23:22:06 -05:00
1 parent 0fe58217ea
commit 3d85cf56d6
1 file changed
+2 -3
+2 -3
View File
@@ -4034,8 +4034,7 @@ private:
PollerWaker waker_; PollerWaker waker_;
// fds_[0] is the waker's, which is always armed; tokens_[i] belongs to // fds_[0] is the waker's, always armed; tokens_[i] belongs to fds_[i].
// fds_[i].
std::vector<struct pollfd> fds_; std::vector<struct pollfd> fds_;
std::vector<Token> tokens_; std::vector<Token> tokens_;
std::unordered_map<socket_t, size_t> index_; std::unordered_map<socket_t, size_t> index_;
@@ -7384,7 +7383,7 @@ inline void drain_and_close_socket(socket_t sock,
const auto n = read_socket(sock, buf, sizeof(buf), CPPHTTPLIB_RECV_FLAGS); const auto n = read_socket(sock, buf, sizeof(buf), CPPHTTPLIB_RECV_FLAGS);
if (n <= 0) { break; } if (n <= 0) { break; }
total += static_cast<size_t>(n); total += static_cast<size_t>(n);
} while (usec_left() > 0 && total < size_t(1024u * 1024u)); // bound #2 } while (total < size_t(1024u * 1024u) && usec_left() > 0); // bound #2
shutdown_socket(sock); shutdown_socket(sock);
close_socket(sock); close_socket(sock);